Swiggy Vignesh Muralidharan Jun 20, 2023

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

Critical Insight

By remapping video requests to 8 width buckets using K-means clustering, Swiggy cut video processing costs in half while improving cache performance.

The article includes the actual code implementation and explains why this bucketing strategy needs continuous monitoring as your app evolves.

About This Article

Problem

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.

Solution

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.

Impact

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.