By default the Java driver has some specific polling options, these may need to be changed if it is observed that threads are getting blocked.
When using the executeAsync method as described here it might still be observed that threads are getting blocked.
The driver blocks because it is waiting for a connection to a host to become available.
With protocol v3 there is 1 connection per host, and each connection can execute a given number of concurrent requests. When that threshold is reached, subsequent requests are queued. The thread will be blocked until a timeout expires, then it moves to the next node.
With v2 there are many connections per node (8 per local node, 2 per remote node), and each connection handles up to 128 simultaneous requests. To handle more requests, you can change the number of connections with:
as described here.
(Note on releases prior to 2.1.6 we recommend setting them to the same value).
There are two things that can be done (possibly a combination of the two):
1. Set more requests per connection with:
The default is 1024, it can be up to 32768.
2. Change the timeout with:
The default is 5000, it can be set to 0 to never block.