AI Hints
Home›System Design Tutorial›Resilience Patterns
System Design · Lesson 81 of 120

Bulkheads

Contain the damage.

⏱ 2 min read▶ Video at 1:37:30🎓 Free
Watch this lesson in the System Design courseWatch on YouTube ↗Full System Design course

Ships are divided into watertight compartments, called bulkheads. If one floods, the ship still floats. Software can use the same idea.

Bulkheads
From the video: Bulkheads
  • Ships have compartments
  • One floods, ship floats
  • Same idea in software

Shared vs separate pools

Imagine the order service has one pool of fifty threads, for calling both payment and recommendations. Recommendations gets slow, and soon all fifty threads are stuck waiting on it. Now payments can't get a thread either. With bulkheads, each dependency gets its own small pool. A slow recommendation service can only block its own ten threads.

One shared pool

  • 50 threads for allOne slow serviceEverything stuck

Bulkheads

  • Payments: 40 threadsRecommendations: 10Damage contained

Bulkheads everywhere

The idea appears at many levels. Separate thread pools per dependency. Separate servers for important customers. Separate queues for urgent and bulk work. And even separate data centres. Wherever one part could exhaust a shared resource, put up a wall.

Thread poolsper dependency
Serversper customer tier
Queuesurgent vs bulk
Regionsseparate failures

Summary

Bulkheads give each part its own resources, so one failure can't consume everything. Next, finding the single parts that could take the whole system down.

Key takeaways
  • Watertight compartments
  • Separate pools
  • Contain failures
Next up: Single Points of Failure — find them, remove them