Maximum number of Astyanax client connections per node?

I am reading data from a Cassandra database using an Astyanax client.

I have about a million unique rows in a Cassandra database. I have one cross colocation center with four nodes.

These are my four nodes:

  node1:9160
  node2:9160
  node3:9160
  node4:9160

I have KeyCaching enabled and the SizeTieredCompaction strategy enabled.

I have a client program that is multi-threaded, which will read data from a Cassandra database using the Astyanax client and which I start with 20 threads. If I run my client program with 20 threads, then the performance of reading data from the Cassandra database is degraded.

So, the first thing that comes to my mind is that there may be disagreement about the connections with Cassandra (they use the pool, if so, how many connections are supported)? I use the code below to establish a connection using the Astyanax client.

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(1)
        .setSeeds("nod1:9160,node2:9160,node3:9160,node4: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());
}

Do I need to make any changes to the above code to improve performance?

What does this method do?

   setMaxConnsPerHost(1)

Does this need to be increased to increase productivity? I have four nodes, so should I change this to 4?

And will call the setMaxConns (20) method? Should I add this to improve performance? Since I will run my program with multiple threads.

+5
source share
1 answer

maxConnsPerHost/maxConns : setMaxConns setMaxConnsPerHost Astyanax

, maxConnsPerHost . , , , , / ..

, .

Cassandra :

maxConnsPerHost ~= <Number of cores per host>/<Replication factor> + 1

8 3 maxConnsPerHost 4. .

: N , C , N * C . R R ( ). , N * C / R. , . N, . 1 .. .

: :

  • maxConnsPerHost
  • org.apache.cassandra.request->***Stage->pendingTasks JXM
  • maxConnsPerHost , pendingTasks . , .
  • 50-70%. - , - .
+9

All Articles