{"canonical_url":"https://engineer.company/glossary/bulkhead-pattern/","content_markdown":"# Bulkhead pattern\n\n## What it is\n\nThe bulkhead pattern isolates a part of a system so its failures or heavy demand\naffect a limited area. A service can give different types of work separate\nqueues, connection pools, worker pools or capacity on separate instances. Each\nboundary has a defined amount of shared resource available. When one part uses\nits allowance, other operations can continue if they still have the resources\nthey need.\n\nIsolation can follow a dependency, a tenant, a class of request or a particular\nset of data. An application might reserve workers for short interactive\noperations and use a separate pool for slow reports. Another design might\nisolate requests to an unreliable external service from ordinary internal reads.\nThe chosen boundary should follow what needs to remain available when one part\nbecomes slow or stops.\n\nA pool by itself provides a limited kind of isolation. The work behind two pools\ncan still share storage, process memory or an upstream provider. Review the path\nend to end and identify where one part can consume capacity another part needs.\nThe pattern is useful when an owner can explain which failures the boundary\ncontains and what limits still apply across the wider service.\n\n## Why it matters\n\nImagine a service that serves product pages and generates large export files. A\nburst of slow exports can fill every worker in a shared pool. The product pages\nmay then wait even though each page needs little work. Giving exports their own\nbounded queue and capacity can preserve responsiveness for browsing while the\nexport system catches up. The waiting requests still need honest status,\ndeadlines and an end to repeated retries.\n\nA boundary also lets teams set different policies for work with different costs.\nA request that opens a product page may need a result quickly. An offline report\ncan wait longer and show its position or the age of the queued request. When the\nreport workload exceeds the resources set aside for it, the service might defer\nnew reports or refuse them clearly. Those choices are easier to make once the\naffected work and the resources it can consume are defined.\n\nThere is a trade-off in reserving resources. An idle pool can leave capacity\nunused while another one is busy. Allowing unlimited borrowing can create the\nsame shared saturation the design was meant to prevent. Use measurements to\ndecide which minimum must be protected and where capacity can be shared within a\ncontrolled limit. Include the failure of any shared connection or service when\ntesting what protection users receive.\n\n## What it looks like in practice\n\nConsider an application sending notifications through a slow partner connection.\nGive the partner requests a fixed number of workers and a bounded queue. Reserve\na different capacity budget for requests that only read application records.\nSend enough slow partner work to fill its queue, then check a normal read.\nMeasure response times for each group, the number of active tasks and the result\nwhen an affected requester tries to submit more work.\n\nExercise a second case where a shared database connection limit is reached. The\nisolated worker pools may still depend on that database. If the normal reads\nslow down too, inspect which capacity the separation actually protects. Reserve\na suitable budget for the work that must continue or redesign the expensive path\nto release its connection while it waits. Record the conditions of the test and\ncompare a real operation on each side of the boundary.\n\nEngineer's\n[limited-stock engineering note](/notes/selling-limited-stock-without-overselling/)\ndescribes scoping a pause to the stock items whose shard is unavailable while\nkeeping other parts of the shop usable. That is a concrete example of defining\nthe affected work and preserving useful work elsewhere. A bulkhead exercise can\napply the same question before a failure occurs. Which users should still be\nable to browse, submit or read a result when one area reaches its limit?\n\n## Where it goes wrong\n\nA bounded worker pool can be paired with an unbounded queue. During a long\noutage the backlog can grow until the process runs out of memory or accepts jobs\nlong after they are useful. Define the queue's length, lifetime and response to\noverload. Make rejection or postponement visible so that an upstream caller can\nchoose how to respond without producing an uncontrolled retry wave.\n\nA different failure arises when a limit is too broad. Placing all partners\nbehind one isolation boundary protects the rest of the application but lets one\npartner delay every other partner. Test where the expected failure originates\nand where it should stop. More pools also mean more configuration and\nobservation, so use a boundary that somebody can operate and measure.\n\nReview retry behaviour when each boundary has its own queue. If a stalled\noperation occupies all its capacity through repeated attempts, it can still\nprevent newer work from finishing within the same boundary. Consider the cost\nand value of each attempt, and record how the service handles an operation that\nhas passed its useful deadline. A short queue can keep the problem visible and\noffer operators a predictable way to restore normal throughput.\n\nFinally, verify the policy across restarts and changes in traffic. Establish how\ntasks already accepted are completed or returned, and check whether a new\ndeployment preserves the intended capacity split. Measure request latency and\ncompletion separately for each workload, including the affected integration and\nthe routes you want to protect. A design is useful when responders can say which\nwork continued, which work was delayed and what resource governed that outcome.\n\n## Further reading\n\n- [Microsoft's Bulkhead pattern guidance](https://learn.microsoft.com/en-us/azure/architecture/patterns/bulkhead).\n  Explains partitioning by service, consumer and resource.\n- [Resilience4j bulkhead controls](https://resilience4j.readme.io/docs/bulkhead).\n  Describes semaphore and thread-pool forms of concurrency isolation.\n- [AWS workload isolation using shuffle sharding](https://aws.amazon.com/builders-library/workload-isolation-using-shuffle-sharding/).\n  Examines another way to limit the set of users affected by shared-worker\n  failures.\n\n\u003chttps://engineer.company/glossary/bulkhead-pattern/\u003e\n","date_modified":"2026-11-25T07:18:46Z","description":"Keep a stalled integration in its own resource pool and verify if the unaffected routes still meet their targets.","formats":{"gemtext":"https://engineer.company/glossary/bulkhead-pattern/index.gmi","gopher":"https://engineer.company/glossary/bulkhead-pattern/gophermap","html":"https://engineer.company/glossary/bulkhead-pattern/","json":"https://engineer.company/glossary/bulkhead-pattern/index.json","markdown":"https://engineer.company/glossary/bulkhead-pattern/index.md","pdf":"https://engineer.company/glossary/bulkhead-pattern/index.pdf"},"kind":"page","language":"en","title":"What is a bulkhead pattern?","url":"https://engineer.company/glossary/bulkhead-pattern/","version":1}