← Back to list

When OkHttp Made Our App Slow: A Deep Dive into Happy Eyeballs, IPv6 & Jio

Sometimes the most frustrating production issues are not backend failures, crashes, or memory leaks.

Pavansairam · 2026-05-23 09:30 · 8 claps · 2.9 min read
#android-development #networking #okhttp #ipv6 #ipv4
Open on Medium ↗
Wiki topics: 🌐 · Web Development 📱 · Mobile Development

When OkHttp Made Our App Slow: A Deep Dive into Happy Eyeballs, IPv6 & Jio

Photo by Ralfs Blumbergs on Unsplash

Photo by Ralfs Blumbergs on Unsplash

Sometimes the most frustrating production issues are not backend failures, crashes, or memory leaks.

Sometimes… everything works perfectly, except on one network.Recently, we faced a strange issue in our company’s Android app:

APIs were working fine

Backend metrics looked healthy

No infrastructure alerts

Yet users on Jio experienced noticeable slowness

At first, we assumed the problem was with our APIs or backend infrastructure.

But after digging deeper, the real issue turned out to be something far more interesting:

IPv6 routing + Cloudflare + older OkHttp connection behavior

And that’s where I learned more about Happy Eyeballs than I ever expected to.

🚨 The Problem

The app was noticeably slow only on Jio networks.

Not failing. Not crashing. Just delayed.

API calls were taking longer than expected before eventually succeeding.

What made the issue harder to debug was:

  • Everything looked normal internally
  • APIs responded fast from server-side monitoring
  • Other networks worked perfectly

So initially, the backend became the primary suspect.

🔍 The Investigation

We started checking:

  • API latency
  • Backend logs
  • Cloudflare metrics
  • CDN behaviorRequest traces
  • Request traces

Everything seemed healthy.

But one important pattern emerged , The issue consistently reproduced on Jio. That immediately shifted our focus from:

“Server issue” to “Network behavior issue”

🌐 Understanding the Real Cause

Our APIs were behind Cloudflare.And like most modern Android devices, Android prefers:

IPv6 over IPv4

Jio has strong IPv6 adoption, which means devices on Jio attempt IPv6 connections first.

The problem was:

  • IPv6 routes through Cloudflare on Jio were slow/intermittent
  • Requests were waiting too long before falling back to IPv4

So the actual request flow looked like this:

  1. Android prefers IPv6
  2. Connection attempt begins
  3. IPv6 route becomes slow
  4. Client waits
  5. Eventually falls back to IPv4
  6. Request succeeds

Result:

Every API request paid an unnecessary delay penalty.

⚡ Where OkHttp Entered the Picture

We were using an older OkHttp version.

At first glance, OkHttp looked unrelated to the issue.

But the deeper we investigated, the more we realized:

The issue was heavily tied to how connection attempts were managed internally.

Specifically: Happy Eyeballs behavior

🧠 What is Happy Eyeballs?

Happy Eyeballs is a networking algorithm designed for dual-stack environments (IPv6 + IPv4).

The goal is simple:

Avoid delays caused by problematic IPv6 networks.

Instead of fully waiting for IPv6 to fail, the client:

  • Attempts IPv6
  • Quickly attempts IPv4 as backup
  • Uses whichever succeeds first

This significantly reduces user-perceived latency.

🔄 Older vs Newer Happy Eyeballs Behavior

🧱 Older Behavior

Older connection handling worked more sequentially:

  • DNS returns IPv6 + IPv4 addresses
  • Client tries IPv6 first
  • Waits longer for success/failure
  • Then falls back to IPv4

This becomes problematic when:

  • IPv6 is slow
  • But not completely broken

Because the client keeps waiting.

⚡ Improved Behavior in Newer OkHttp

Newer OkHttp versions improved this behavior significantly.

Instead of waiting too long:

  • IPv6 starts first
  • IPv4 begins shortly after
  • Faster connection wins

This aligns much closer to modern Happy Eyeballs principles.

Result:

Slow IPv6 no longer blocks fast IPv4 connections.

🚀 The Fix

We upgraded to:

OkHttp 5.x

And the improvement was immediately noticeable.

But the upgrade itself wasn’t straightforward.

To support newer OkHttp versions, we also had to:

  • Upgrade Kotlin
  • Update Koin dependencies
  • Resolve transitive dependency conflicts
  • Revisit timeout configurations

Additionally, we reduced connection timeout values to avoid prolonged waits during slow IPv6 attempts.

✅ The Result

After the upgrade and optimizations:

  • API latency improved significantly on Jio
  • Requests became more consistent
  • User experience stabilized across networks

Most importantly:

The “backend issue” turned out to be a client-side networking behavior problem.

💡 Key Takeaways

  • Not all latency issues are backend problems
  • IPv6 vs IPv4 behavior can impact real-world performance
  • ISP-specific routing (like Jio) matters more than expected
  • Networking libraries evolve — upgrading can fix hidden issues
  • Understanding connection strategies is crucial for mobile apps

🎯 Final Thoughts

This issue taught me an important lesson:

Performance debugging is not just about APIs and servers.

Sometimes the real bottleneck exists in:

  • DNS resolution
  • Network routing
  • IPv6 fallback behavior
  • Connection management strategies

And in our case, understanding Happy Eyeballs made all the difference.

📚 References


메타데이터
post_id
b60bbbd5f90a
slug
when-okhttp-made-our-app-slow-a-deep-dive-into-happy-eyeballs-ipv6-jio-b60bbbd5f90a
url
https://medium.com/@pavansairamjatlaiiit/when-okhttp-made-our-app-slow-a-deep-dive-into-happy-eyeballs-ipv6-jio-b60bbbd5f90a
canonical_url
https://medium.com/@pavansairamjatlaiiit/when-okhttp-made-our-app-slow-a-deep-dive-into-happy-eyeballs-ipv6-jio-b60bbbd5f90a
author_url
https://medium.com/@pavansairamjatlaiiit
status
ok
fetched_at
2026-06-17 12:58:54