# Throttling, Backpressure and Graceful Degradation

> Stay up under overload by shedding, deferring or reducing work instead of collapsing. Free notes, key concepts, resources and a mini project.

Canonical: https://www.internhack.in/roadmaps/tracks/backend/load-management
Last updated: 2026-11-28

Stay up under overload by shedding, deferring or reducing work instead of collapsing.

Advanced · about 4 hours · difficulty 4/5

Learn first: [Timeouts, Retries and Circuit Breakers](https://www.internhack.in/roadmaps/tracks/backend/resilience-patterns), [Pagination, Versioning and Rate Limits](https://www.internhack.in/roadmaps/tracks/backend/api-evolution-and-limits), [Background Jobs and Task Queues](https://www.internhack.in/roadmaps/tracks/backend/background-jobs)

Every system has a maximum capacity. What matters is what happens beyond it: a well-designed service slows down gracefully and keeps serving its most important traffic; a poorly designed one falls over completely and takes a long time to recover.

### Throttling and rate limiting

Limit how much work each client or tenant may send (token bucket, sliding window), returning `429 Too Many Requests` with `Retry-After`. Per-tenant limits stop one noisy customer from degrading everyone else.

### Load shedding

When the server itself is overloaded, reject some requests early and cheaply (for example a `503`) rather than accepting everything and timing out on all of it. Shed **low-priority** traffic first: background syncs and analytics before checkout and login. Bounded queues with a max wait time are a simple form of this.

### Backpressure

Producers must slow down when consumers cannot keep up. Examples: bounded in-memory queues, stream `highWaterMark` in Node, consumer prefetch limits in brokers, and HTTP clients honoring 429s. Unbounded buffers only turn overload into out-of-memory crashes.

### Load shifting and leveling

Move non-urgent work out of the peak: put it on a **queue** and let workers process at a steady rate, precompute results off-peak, and schedule batch jobs at night. The queue absorbs spikes that would otherwise hit the database.

### Graceful degradation

Decide ahead of time which features can switch off: hide recommendations, serve cached or slightly stale data, disable expensive search filters, or show a read-only mode. **Feature flags** make these switches fast during an incident.

### Recovery

After an outage, a backlog of retries can knock the system down again (a **thundering herd**). Jittered retries, limits on queue drain rate and warm-up of caches prevent a second collapse.

You are ready to move on when you can overload your service in a test and show it keeps serving priority endpoints while shedding the rest.

## Key concepts

- **Per-client and per-tenant throttling**
- **Load shedding and priorities**
- **Backpressure**
- **Queue-based load leveling**
- **Graceful degradation with feature flags**
- **Thundering herd on recovery**

## Mini project

Add per-tenant rate limits and a priority-aware load shedder to your API, then run a load test above capacity and show login and checkout stay healthy while low-priority endpoints return 503.

## Check yourself

What is the difference between rate limiting a client and load shedding on the server, and when do you need each?

## Free resources

- [SRE Book: Handling Overload](https://sre.google/sre-book/handling-overload/) (Google)
- [SRE Book: Addressing Cascading Failures](https://sre.google/sre-book/addressing-cascading-failures/) (Google)
- [Queue-Based Load Leveling pattern](https://learn.microsoft.com/en-us/azure/architecture/patterns/queue-based-load-leveling) (Microsoft Learn)

Previous: [Timeouts, Retries and Circuit Breakers](https://www.internhack.in/roadmaps/tracks/backend/resilience-patterns) · Next: [Zero-Downtime Deploys and Migrations](https://www.internhack.in/roadmaps/tracks/backend/zero-downtime-changes)

## More in Building for Scale and Resilience

- [Vertical and Horizontal Scaling](https://www.internhack.in/roadmaps/tracks/backend/scaling-strategies)
- [Timeouts, Retries and Circuit Breakers](https://www.internhack.in/roadmaps/tracks/backend/resilience-patterns)
- [Throttling, Backpressure and Graceful Degradation](https://www.internhack.in/roadmaps/tracks/backend/load-management)
- [Zero-Downtime Deploys and Migrations](https://www.internhack.in/roadmaps/tracks/backend/zero-downtime-changes)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Backend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/backend)
