I am using Astyanax client
to read the data from Cassandra database
. I have a single cluster
with four nodes
. I am having replication factor of 2
. I am trying to understand what is the difference between
setMaxConns and setMaxConnsPerHost
methods in Astyanax client? I cannot find proper documentation on this.
I have a Multithreaded code which which spawn multiple threads and then create the connection to Cassandra database only once (as it is a Singleton) and then keep on reusing for other request.
Now I am trying to understand how the above two methods will play a role in read performance? And How those values should be set up?
And If I am setting those above two methods as-
setMaxConns(-1) and setMaxConnsPerHost(20)
then what does it mean? Any explanation will be of great help.
Updated Code:-
Below is the code, I am using to make the connection-
private CassandraAstyanaxConnection() {
context = new AstyanaxContext.Builder()
.forCluster(ModelConstants.CLUSTER)
.forKeyspace(ModelConstants.KEYSPACE)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
)
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
.setPort(9160)
.setMaxConnsPerHost(20)
.setMaxConns(-1)
.setSeeds("host1:9160,host2:9160,host3:9160,host4:9160")
)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setCqlVersion("3.0.0")
.setTargetCassandraVersion("1.2"))
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
keyspace = context.getEntity();
emp_cf = ColumnFamily.newColumnFamily(
ModelConstants.COLUMN_FAMILY,
StringSerializer.get(),
StringSerializer.get());
}
If I am debugging this code, it is not even hitting the BagOfConnectionsConnectionPoolImpl
class. I put a lot of breakpoint in the same class to see how it is using the conenctions and other default parameters. But don't know why it is not hitting that class.
WildFire
for the suggestion. In my case, I am usingConnectionPoolConfigurationImpl
class for the connection pooling. And I tried debugging the code by putting lot of breakpoints, and it's not even hitting theBagOfConnectionsConnectionPoolImpl
class anywhere? Is there anything, I am missing here? I was trying to compare Pelops vs Astyanax client. So by default Pelops has 20 connections per node and maximum connections is set as -1 , so that is the reason I followed the same connection parameters in Astyanax as well. Let me know if I am missing anything. – Geminate