CodePark/ questions / Retries, timeouts & resilience
START PRACTICINGPRACTICE
Backend question · System design & architecture › Retries, timeouts & resilience

Explain the bulkhead pattern and graceful degradation, with an example from an e-commerce product page.

A bulkhead keeps resources separate, so one failing part cannot use them all up. Think of the walls between compartments in a ship: if one compartment floods, the others stay dry. In a service, you give each dependency its own resources, for example:

  • its own connection pool
  • its own concurrency limit (the most requests it can have open at once)
  • or even its own separate instances

Say the recommendations service hangs. Only its small pool fills up. Requests to pricing and inventory still have free capacity.

Graceful degradation means the page keeps working with fewer features when a non-critical dependency fails. It does not fail completely. On a product page, the price, the stock and the buy button are critical. Recommendations, reviews and "recently viewed" are not critical. If they time out, you can:

  • hide that section
  • show cached or default content
  • keep the rest of the page fast

Use these two patterns together with short timeouts and circuit breakers. A circuit breaker stops calling a dependency after it fails many times. Together, they keep a partial outage partial, so it does not spread to the whole page. Decide in advance which features are critical. Also test the degraded paths, so you know they really work.

  • A bulkhead gives each dependency its own pool or limit.
  • One slow dependency cannot use up the shared resources.
  • Non-critical features degrade, but the core flow keeps working.
  • Fallbacks are hiding the section, or showing cached or default content.
  • Decide in advance which features are critical and which are optional.