I use Astyanax clientto read data from Cassandra database. I have single clusterwith four nodes. I have one replication factor of 2. I'm trying to understand what is the difference between
setMaxConns and setMaxConnsPerHost
in an Astyanax client? I can not find the relevant documentation on this.
I have multi-threaded code that spawns multiple threads and then creates a connection to the Cassandra database only once (since it's Singleton) and then continues reusing for another request.
Now I'm trying to understand how these two methods will play a role in read performance? And how should these values be configured?
And if I set these two methods above as -
setMaxConns(-1) and setMaxConnsPerHost(20)
what does that mean? Any explanation would be very helpful.
Updated Code: -
, -
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());
}
, BagOfConnectionsConnectionPoolImpl. , , . , .