After upgrading the application to use cassandra-client-driver 4.4.0 (from 3.X) , we are seeing the following differences
a) Application connects to all the cassandra nodes and driver establishes connections to all cassandra nodes
b) These established connections are not closed when the application is idle. If there are 6 cassandra nodes in the ring, application holds connection to all the 6 cassandra nodes and those 6 connections are not closed even when the application fires only one or two cassandra-queries per second.
Behavior -(b) was different in 3.x where connections are teared down except for one or two connections to subset of cassandra nodes. We are worried behavior-(b) would end up creating too many connections when there are 30 nodes in cassandra ring and application creating 30 connections and holding on to it redundantly.
Here is the builder settings used in 4.4.0:
ProgrammaticDriverConfigLoaderBuilder builder = DriverConfigLoader.programmaticBuilder() .withString(PROTOCOL_VERSION, ProtocolVersion.V3.name()); builder = builder.withInt(CONNECTION_POOL_LOCAL_SIZE, 1); builder.withDuration(10000, Duration.ofMillis(connectionTimeoutMillis)); builder.withDuration(10000, Duration.ofMillis(readTimeoutMillis)); builder.withBoolean(SOCKET_KEEP_ALIVE, true); builder.withClass(LOAD_BALANCING_POLICY_CLASS, DefaultLoadBalancingPolicy.class); builder.withBoolean(REQUEST_DEFAULT_IDEMPOTENCE, true); builder.withClass(RETRY_POLICY_CLASS, DefaultRetryPolicy.class); builder.withString(REQUEST_CONSISTENCY, ConsistencyLevel.LOCAL_QUORUM.name());
Is there any property to set the idle timeout to close the unused connections