connection pool in cassandra v3

1,683 views
Skip to first unread message

Karthick V

unread,
Aug 29, 2016, 3:05:46 AM8/29/16
to DataStax Java Driver for Apache Cassandra User Mailing List
hi,
    i am new Cassandra and  i got little bit confused about session & connectivity .In DataStax it is defined as ever session object makes its own connection pool with 32k Stream id(In ip v3).let say that i have 10 app server, Now the Question how many connection pool they can make maximumly .if i'm not wrong every instance make a connection pool then how instance can access the cluster at the same time and please notify if i am wrong with the basic

Andrew Tolbert

unread,
Aug 29, 2016, 12:17:58 PM8/29/16
to DataStax Java Driver for Apache Cassandra User Mailing List
Hi Karthick,

Each Session has a connection pool for each host, and each host can have a number of connections in its pool, with each connection having 32k stream ids (but by default the driver will only use 1k).   The connection pooling doc in the manual is helpful for understanding these considerations.

Creating more Cluster/Session instances isn't usually a good pattern because there really isn't a reason to other than for supporting different configurations.  As covered in: "4 simple rules when using the DataStax drivers for Cassandra" :

  1. Use one Cluster instance per (physical) cluster (per application lifetime)
  2. Use at most one Session per keyspace, or use a single Session and explicitely specify the keyspace in your queries
It is very likely not going to help you to increase throughput/capability by having more than 1 Cluster & Session.  If you are worried about achieving ideal throughput, you will need to test and tune based on your findings.  It is hard to find a 'one size fits all' configuration, but typically the default settings in the driver with 1 Cluster & Session object will be adequate for you/. If not, increasing the number of core connections to 8 in PoolingOptions may help.

Thanks,
Andy

Karthick V

unread,
Aug 31, 2016, 1:43:30 AM8/31/16
to DataStax Java Driver for Apache Cassandra User Mailing List
thanks for reply.And in this part "each host can have a number of connections in its pool"  I still wonder about the maximum number of connections a host node can manage in its pool ,is there any limit or else it is hardware dependent ? 

Kevin Gallardo

unread,
Aug 31, 2016, 5:53:04 AM8/31/16
to java-dri...@lists.datastax.com
The maximum number of connections per-host can be set in the PoolingOptions, the default max connections per host for Protocol V1 is 8, the max for protocol > V1 is 1. 

In theory the maximum number of open connections you can have is the maximum number of open TCP sockets the OS can handle... However it is very recommended to open the least number of connections possible, as managing an open connection costs resources for the driver, the OS, and consequently the application. The driver has an algorithm to dynamically size the pools according to the current load in order to only open connections when it's needed. Everything is detailed in the link Andrew provided.

Hope that answers your question. 
Cheers.

--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-user+unsubscribe@lists.datastax.com.



--
Kévin Gallardo.
Software Engineer in Drivers and Tools Team at DataStax.
 
Reply all
Reply to author
Forward
0 new messages