Key Concepts
To understand how the system was designed to handle sudden traffic spikes, the following concepts are referenced throughout this case study:
- Requests Per Second (RPS): Indicates how much traffic a system can handle at any given moment. Higher RPS capacity means the system can support more users and activity without slowing down or failing.
- Serverless Architecture: An application design approach where infrastructure is managed by the cloud provider instead of fixed servers. This allows the system to scale automatically as traffic increases, making it suitable for unpredictable or sudden demand.
- Cloudflare Workers: The serverless platform used to implement this architecture. It runs application code at the network edge, close to users, which reduces latency and enables fast, consistent performance at a global scale.
- Durable Objects: Used alongside Cloudflare Workers to safely manage shared information (such as counters, sessions, or live state) when many users interact with the system at the same time. They ensure updates occur in the correct order, keeping behaviour predictable and data accurate under high concurrency.
Business Problem
The client had developed an API that was still in a pre-production state, intended for a high-profile market launch. Ahead of release, we were asked to assess whether the system was ready for production use. During this audit, it became clear the API was not prepared for real-world traffic.
Under even moderate request volumes, the architecture began to fail, revealing three critical risks:
- Infrastructure Not Built to Scale: The existing code was not designed to scale. Any increase in activity would have required manual, expensive, and slow infrastructure changes, effectively putting a ceiling on the company's growth potential.
- Unsafe Concurrency Handling: When multiple users interacted with the system at once, the API exhibited unstable behaviour. Without intervention, this would have led to data corruption, inconsistent system states, and total crashes under load.
- High Risk of Launch Failure: Had the system gone live, even modest marketing success would have triggered immediate instability. This would have resulted in downtime during the launch window and a permanent loss of customer trust.
The system required a complete re-architecture to ensure the product could launch reliably, protect data integrity, and scale effortlessly as demand grew.
Our Solution
We redesigned the backend to eliminate scalability limits and ensure reliable behaviour under high-volume traffic.
- Seamless Integration: We preserved the existing API structure to enable a "hot swap" transition. This allowed the new backend to be deployed by updating a single endpoint, minimising risk and requiring zero changes to the frontend.
- Automated Scaling at the Edge: Request handling is distributed across a global network, allowing traffic to be processed close to the user. This ensures consistent performance during sudden spikes without the need for manual server provisioning.
- Reliable Coordination Under Load: We implemented Durable Objects to safely manage shared state. This resolved the concurrency issues identified in the audit, ensuring data remains accurate and predictable under intense load.
This transformation turned a fragile prototype into a robust, enterprise-grade system capable of handling 5,000 requests per second (a 100x improvement) while remaining stable and efficient.
Results
A production-ready backend capable of sustaining 5,000 RPS with zero manual scaling.
- 100x Increase in Capacity: The system was load-tested to reliably handle up to 5,000 requests per second, a significant improvement over the original limits and enough to support sudden traffic surges from marketing or public launches.
- Stable, Production-Ready Launch: The API was released without incidents, maintaining full availability and consistent performance for early users from day one.
- Reduced Operational Overhead: By adopting a serverless model, infrastructure costs were aligned with actual usage. The client now pays only for traffic handled, rather than maintaining idle server capacity.
- Confidence to Scale: With technical risks addressed before launch, the team was able to pursue growth initiatives without concern that the system would fail under increased demand.
With a production-ready, scalable foundation in place, the client can now pursue growth without technical limitations or operational risk.