Java driver connectionsPerHost and newConnectionThreshold

237 views
Skip to first unread message

folex

unread,
Jul 30, 2015, 8:46:00 AM7/30/15
to DataStax Java Driver for Apache Cassandra User Mailing List
I want to understand how PoolingOptions::ConnectionsPerHost and PoolingOptions::NewConnectionThreshold works.
I expect them to add new connection when NewConnectionThreshold is reached, until MaxConnectionsPerHost reached, but looks like number of connections stays at coreConnectionsPerHost.
I monitor number of connections via 
watch -d -n0 "netstat -atnp | awk 'NR <= 2 || /9042/'"
on cassandra side.

Are my expectations correct? If not, is there anything except source code where behaviour is specified? 
If there is no doc/spec about that, where exactly (at least filename) should I look in source code? I've tried, but was unable to find queue implementation.

Here is example scala project.

Thanks in advance.

Kevin Gallardo

unread,
Jul 30, 2015, 10:28:22 AM7/30/15
to DataStax Java Driver for Apache Cassandra User Mailing List, 0xd...@gmail.com
Hello, 

Detailed information can be found here about pooling options and newConnectionThreshold.
Your description of the behaviour looks a bit incomplete, as stated in the documentation : a new connection is created " if all but the last connection are full, and the last connection is above this threshold.". So before creating a new connection, the driver checks if it is possible to send the request on another connection not full (using maxRequestsPerConnection).

Are you sure all connections are full in your case ?

Kevin Gallardo

unread,
Jul 30, 2015, 10:30:21 AM7/30/15
to java-dri...@lists.datastax.com
On Thu, Jul 30, 2015 at 3:28 PM, Kevin Gallardo <kevin.g...@datastax.com> wrote:
Hello, 

Detailed information can be found here about pooling options and newConnectionThreshold.
Your description of the behaviour looks a bit incomplete, as stated in the documentation : a new connection is created " if all but the last connection are full, and the last connection is above this threshold.". So before creating a new connection, the driver checks if it is possible to send the request on another connection not full (using maxRequestsPerConnection).

Are you sure all connections are full in your case ?
all other** connections are full

On Thursday, July 30, 2015 at 1:46:00 PM UTC+1, folex wrote:
I want to understand how PoolingOptions::ConnectionsPerHost and PoolingOptions::NewConnectionThreshold works.
I expect them to add new connection when NewConnectionThreshold is reached, until MaxConnectionsPerHost reached, but looks like number of connections stays at coreConnectionsPerHost.
I monitor number of connections via 
watch -d -n0 "netstat -atnp | awk 'NR <= 2 || /9042/'"
on cassandra side.

Are my expectations correct? If not, is there anything except source code where behaviour is specified? 
If there is no doc/spec about that, where exactly (at least filename) should I look in source code? I've tried, but was unable to find queue implementation.

Here is example scala project.

Thanks in advance.

To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.



--
Kevin Gallardo, 
Drivers and Tools Team
DataStax.

Olivier Michallat

unread,
Jul 30, 2015, 10:35:43 AM7/30/15
to java-dri...@lists.datastax.com
Hi,

In addition to the javadoc (link provided by Kevin), you can also check the online doc here (use the dropdown at the top left to pick your driver version). The "dynamic resizing" section explains the algorithm to decide when to add connections.

If you're interested in the source code, it's in HostConnectionPool.

--

Olivier Michallat

Driver & tools engineer, DataStax


To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.

folex

unread,
Jul 30, 2015, 10:38:19 AM7/30/15
to DataStax Java Driver for Apache Cassandra User Mailing List, kevin.g...@datastax.com
I'm not really sure, since I don't really know how to check that. Is there a way?
But I've seen a lot of requests failing with timeout when settings are 
connectionsCore = 1, connectionsMax = 1, threshold = 1
, and I guess that could mean that connections are full since it's unlikely that single client with such settings made cassandra-server go slow.
Reply all
Reply to author
Forward
0 new messages