NOTE

2.43 Thread Isolation

Thread isolation separates calls into distinct thread resources to prevent failing calls from exhausting a service. These notes use Hystrix configuration and execution as examples.

JavaCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. Why Is Thread Isolation Needed?

Prevent problematic calls from exhausting the thread resources of the entire service.

2. Isolation Modes

2.1. Normal Mode

By default there are 10 thread pools, as shown below.

2.2. Bulkhead Mode

3. Thread Pool vs. Semaphore

  • Thread-pool isolation
    • Uses an independent thread pool.
    • Supports queuing and timeouts.
    • Supports asynchronous calls.
    • Thread calls introduce additional overhead.
    • Suitable for:
      • trusted clients;
      • high fan-out (gateway);
      • high-frequency, high-speed calls (cache).
  • Semaphore isolation
    • Uses the caller’s own thread.
    • Lightweight, with no additional overhead.
    • Does not support task queuing or active timeout.
    • Does not support asynchronous calls.
    • Suitable for:
      • untrusted clients;
      • limited fan-out.

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub