Caching and Performance Engineering · Performance and Scalability

Resilience Under Load

Timeouts, backpressure, load shedding and graceful degradation.

Systems fail under overload by queueing until everything times out. Protect them with timeouts on every call, bounded queues and backpressure, load shedding (reject excess or low-priority requests early with 429/503), circuit breakers, bulkheads, and graceful degradation (disable non-essential features, serve cached data). Autoscale, but remember downstream systems may not scale as fast.

Admission control in a gateway/service
if inflight_requests > max_concurrency:            # e.g. 200 per instance
    if request.priority == "low":                  # recommendations, analytics
        return 503, {"Retry-After": "2"}           # shed early, cheaply
if dependency_breaker("recommendations").open:
    return cached_popular_items()                  # degrade gracefully

Common pitfalls

  • Unbounded queues hiding overload until memory runs out.
  • Retries amplifying overload.
  • Autoscaling the app while the database is the bottleneck.

Key points

  • Fail fast beats slow failure
  • Shed low-priority load first
  • Degrade non-essential features

Further reading: Google SRE: Cascading failures

Practice questions

Why is load shedding better than letting requests queue?

Answer

Queued requests eventually time out after consuming resources, so everyone gets errors; shedding some requests quickly keeps the system healthy for the rest.

What is graceful degradation?

Answer

Keeping core functionality available during overload or partial failure by disabling or simplifying non-essential features.

Open in the app to mark lessons complete, take notes and track your progress.