Skip to content
Damian Turczynski edited this page Oct 24, 2017 · 1 revision

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/or 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 within the Bulkhead will begin getting rejected instead of executed, resulting in an immediately-thrown BulkheadRejectedException.

Implementation

Bulkheads are implemented using a counting semaphore. Prior versions of Mjolnir used thread pools for Bulkheads, but the newer Command API introduced in v2.6.0 replaced them with semaphores to reduce complexity and overhead, and help to get away from a problematic SmartThreadPool dependency. See the v2.6.0 Release Notes for more information.

Configuration

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


« Timeouts and CancellationCircuit Breakers »