Rewriting the Network Connection Layer in Our Android Apps
Article Summary
Zomato's Android app was slow. Their network layer was the bottleneck, costing them speed, bandwidth, and user patience.
The Zomato engineering team dissected their entire networking stack—HTTP client, async operations, and data parsing—to identify what was killing performance. They benchmarked alternatives and made bold migration decisions despite the massive code changes required.
Key Takeaways
- Switching from Apache to OkHttp cut average response time by 30%
- Replaced AsyncTask with Retrofit for true concurrent background threads
- GSON beat Jackson and VTD-XML in parsing speed tests
- HTTP/2.0 enabled socket sharing across connections to same host
- Reduced parser code from 30,000 lines to reflection-based approach
By modernizing their stack with OkHttp, Retrofit, and GSON, Zomato achieved 30% faster responses and dramatically simplified their codebase.
About This Article
Zomato's Android app used Apache HTTP client, which was deprecated in Android 6.0. The team had built their own GZIP compression and relied on AsyncTask, but couldn't cancel network calls once they started. This made it hard to optimize bandwidth and give users control over their experience.
Zomato switched to OkHttp, which has built-in GZIP compression and HTTP/2.0 support. They replaced AsyncTask with Retrofit, which let them run true concurrent background threads and cancel network calls when needed.
HTTP/2.0 allowed socket sharing across connections to the same host. The parser code went from 30,000 lines of static code down to a reflection-based GSON approach. This cut down development work and made the app simpler overall.