Zomato Nov 22, 2022

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

Critical Insight

By modernizing their stack with OkHttp, Retrofit, and GSON, Zomato achieved 30% faster responses and dramatically simplified their codebase.

The article includes actual benchmark screenshots showing millisecond-by-millisecond parsing comparisons that influenced their final decision.

About This Article

Problem

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.

Solution

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.

Impact

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.