Enhancing Chat Performance on PhonePe Android - Part 1
Article Summary
Ayush Bagaria from PhonePe set out to cut chat latency by 50% in their P2P payment flow. The journey taught some expensive lessons about the gap between POC results and production reality.
PhonePe's Android team tackled performance issues in their peer-to-peer payment chat feature, one of their most critical user flows. This first installment covers three optimization approaches: debugging slow database queries, experimenting with deserialization libraries, and implementing pagination.
Key Takeaways
- Protobuf showed 5x faster deserialization in POC but matched GSON in production due to caching
- Pagination reduced chat roster load time by 30-33% at P90 (from 3+ seconds to 2+ seconds)
- SQLite Explain Query revealed most slow queries came from complex joins, not missing indexes
- GSON caching cuts repeat deserialization from 200ms to 25-35ms, negating library swap benefits
Critical Insight
These three approaches collectively improved latency by 20%, with the biggest lesson being that POC performance gains don't always translate to production environments.