liveBook · Manning

Thread pool exhaustion

As explained in Troubleshooting Java, Second Edition

Thread pool exhaustion is a condition in which all available worker threads are occupied, preventing additional tasks from executing.

Thread pool exhaustion occurs when every worker thread is occupied and incoming tasks cannot execute. Tasks may block, queue, or drop, causing latency, timeouts, and wider cascading failures. section 12.3.1

Investigate the condition by connecting symptoms to blocked downstream work:

  • Inspect thread dumps for many WAITING or TIMED_WAITING threads sharing a remote-call stack trace. section 12.3.1
  • Look for blocked HTTP clients, socket reads, connection pools, or calls such as RestTemplate.exchange() and HttpClient.send(). section 12.3.1
  • Use trace IDs and spans to compare client and downstream-service durations and locate the slow operation. section 12.4

Blocked payment requests

A thread dump shows servlet workers parked in CompletableFuture.get() while RestTemplate.exchange() waits for a payment gateway. Repeated traces indicate that a slow downstream call is occupying upstream threads.

How Troubleshooting Java, Second Edition covers it

How deep it goes
Defines pool behavior and gives thread-dump and trace-based diagnosis, stopping short of remediation procedures.
Examples
Uses servlet-worker thread dumps, blocked payment-gateway calls, and checkout-to-payment latency spans.
What it assumes
Assumes familiarity with Java applications, remote calls, thread dumps, and service communication.
What you can do after
Diagnose thread pool exhaustion by interpreting repeated blocked-call stacks and tracing downstream latency.
How it connects
Connects thread pools with cascading failures, blocking I/O, thread dumps, distributed tracing, retries, and timeouts.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java, Second Edition. The section links point to the parts of the book it draws on.