.NET Architecture & System Design Interview Question #198

How would you design an API for a sudden traffic spike?

Deployment, Cloud Operations, SRE & Senior System Design Scenarios Senior Advanced

Quick Interview Answer

Protect the system at several layers: use caching where responses permit it, rate or concurrency limits at the edge, horizontal scaling for stateless compute, and queues for work that does not require immediate completion.

Detailed Explanation

Protect the system at several layers: use caching where responses permit it, rate or concurrency limits at the edge, horizontal scaling for stateless compute, and queues for work that does not require immediate completion.

Identify downstream limits before increasing front-end capacity. Load shedding, timeouts, bounded retries, and observability help prevent a spike from turning into a cascading failure.

Code Example

Traffic spike
    |
CDN / Cache
    |
Rate Limit
    |
Autoscaled API
    |
Queue async work
    |
Protect DB/dependencies