Request Queuing and Pool Saturation
The Cassandra Java Driver does not treat a saturated request queue as a trigger for connection renewal. Saturation is viewed as a capacity limit rather than a connectivity failure. When the number of in-flight requests reaches the maxRequestsPerConnection limit across all active connections in the pool, the driver queues the request locally. This queuing occurs independently of the connection's health; the driver assumes the connection is functional but currently fully utilized.
NoHostAvailableException vs. Queuing
The distinction between a queued request and a NoHostAvailableException depends on whether the driver can identify a viable path to the cluster:
- Queuing: Occurs when the connection is established and healthy, but the stream ID limit (multiplexing limit) is reached. The request waits for an available slot. If it waits longer than the configured request timeout, it will eventually fail, but not because the host is "unavailable."
- NoHostAvailableException: This is thrown when the driver's load balancing policy cannot find any host that is currently marked as
UP. This happens if all connections to all hosts have been dropped, or if the driver has explicitly marked hosts as DOWN due to heartbeat failures or repeated connection timeouts.
Likely Behavioral Explanation
In most scenarios, if you see a spike in client-side latency while server-side metrics remain stable, the driver is likely queuing requests. The driver prioritizes reconnection attempts based on the ReconnectionPolicy, which is triggered by TCP-level drops or heartbeat timeouts, not by the volume of requests. A saturated pool does not trigger a reconnect because the TCP stream is still open; it is simply full.
Verification Steps
To determine if saturation is the root cause, use the following scoped checks:
- Monitor Driver Metrics: Track
pool.in-flight. If this value consistently hits your configured maximum, the driver is saturating.
- Compare Latency: Compare the application's measured request latency against the Cassandra server's
coordinator_read_latency. A significant gap indicates client-side queuing.
- Test Capacity: Temporarily increase
advanced.connection.pool.local.size (Driver 4.x) or pooling.local.max_requests_per_connection (Driver 3.x) to see if the NoHostAvailableException frequency decreases or latency shifts.
Diagnostic Detail Needed: Are you observing NoHostAvailableException specifically during peak traffic bursts, or is it occurring randomly regardless of request volume?