Improving Video Cache Hits on Swiggy Apps
Article Summary
Swiggy was bleeding money on video bandwidth costs. The culprit? Videos being requested at 270px, 272px, 275px... you get the idea.
Vignesh Muralidharan from Swiggy's Consumer Apps team breaks down how they tackled video cache inefficiency. Despite great UX, their CDN cache hit ratio was terrible because the same video was being transformed hundreds of times at slightly different widths.
Key Takeaways
- Used K-means clustering to bucket video widths into 8 discrete sizes
- Reduced video processing costs by 50% with minimal quality impact
- Cache hit ratio improved dramatically by eliminating near-duplicate requests
- Standard deviation of ~100px per bucket is negligible on modern displays
By remapping video requests to 8 width buckets using K-means clustering, Swiggy cut video processing costs in half while improving cache performance.
About This Article
Swiggy was requesting videos at many different widths, often varying by just a few pixels. This fragmentation wasted video processing credits and made the app slower.
Vignesh Muralidharan's team used K-means clustering to organize the width data into 8 discrete buckets. They built a Bucketizer component that remaps video URLs to these cluster centroids before making network requests.
Video processing costs dropped by 50% and cache hit ratio improved noticeably. Each bucket has a standard deviation of about 100 pixels, which is small enough that modern smartphone displays don't show the difference.