Swiggy Shubham Singla Dec 19, 2023

Optimising the Swiggy Restaurant App

Article Summary

Swiggy's restaurant app was crashing under load. Their React Native app couldn't handle more than 100 orders on budget devices, and they needed to scale 10x.

The Swiggy engineering team shares their journey optimizing their restaurant partner app from single-outlet to multi-outlet support. What started as obvious fixes led to discovering a critical throttling issue that was destroying performance.

Key Takeaways

Critical Insight

Throttling Firebase Cloud Messaging events was the breakthrough that cut API calls in half and enabled the app to scale from single to multi-outlet support without crashes.

The engineer's debugging approach (coffee, yoga, and systematic observation) reveals why the first two optimization attempts completely failed.

About This Article

Problem

During peak hours, Swiggy's restaurant app made 150 consecutive Fetch Orders API calls. This happened because 30 active orders changed state across 5 stages. The system got overwhelmed with redundant network requests.

Solution

Shubham Singla's team added FCM event throttling logic. It groups multiple Firebase Cloud Messaging events and consolidates them into fewer API calls. The throttling uses a 10-second interval threshold.

Impact

API calls dropped by 50%, which improved network performance. The app can now handle 600+ orders across all device segments. Previously it would crash when handling 100-600 orders depending on RAM capacity.