Skip to content

Bulkheads

Rob Hruska edited this page Mar 5, 2016 · 15 revisions

Important

The documentation in this Wiki is for version 2.6.0, which is not yet released. Documentation for the current version (2.5.0) is in the master README.md.


Bulkheads help guard against one type of operation consuming more than its share of resources and starving out other operations. In essence, it's a limit on the number of concurrent calls for a Command or group of Commands.

Imagine we have an operation that makes a network call to an external service. If that downstream service becomes very slow, our own application will start building up pending operations that are waiting for the downstream service to respond. Depending on how the call is implemented, this can begin to accumulate finite resources like threads, connections, and memory. If left unbounded, this can result in fewer (or no) resources for other, unrelated operations to work with.

To prevent this, Commands are grouped into Bulkheads. When the Bulkhead is at capacity, Commands will begin getting rejected instead of executed, resulting in an immediately-thrown CommandRejectedException.

Implementation

Bulkheads are implemented using a counting semaphore. Prior versions of Mjolnir used thread pools for Bulkheads, but version 2.6.0 replaced them with semaphores to reduce complexity and help to get away from a problematic SmartThreadPool dependency. See the 2.6.0 Release Notes for more information.

Configuration

Several properties of each Bulkhead can be configured at runtime. See Configuration Keys for details.

===== « Timeouts and CancellationCircuit Breakers »