Search code examples
cassandradriverconnection-poolingdatastax-java-driver

How many pools per session for Cassandra Java Driver?


I was reading this article on Cassandra connection pooling, and it says:

For each Session, there is one connection pool per connected host

But then it has the following diagram which shows 1-n on Session-Pool:

connection objects ratios So, how many pools per session the driver manages after all? Is this customizable?


Solution

  • For each session driver have one control & N data connections (configurable) per connected host. You can configure number of connections as described in documentation, potentially setting different number of connections for local & remote connections (if you're using DC-aware load balancing policy).

    By default the number of data connections for V3 protocol is one - that's enough, especially if you increase the number of "in-flight" requests to high number (V3 allows to have up to 32k "in-flight" requests). If you combine high number of "in-flight" requests with async operations, you can reach quite high throughput, but you may need to take care that you won't issue too many requests. (I use following class to control it).