0

I am doing load testing on Cassandra By using JMeter. After systematically increasing the load, I can see that more than 58000 Active connection has been established by the driver with different node of cassandra.
I have started with 500 and added up 500 more after 10 iteration. like this i reached upto 2500 request. where it is failing. And Throwing NoHOSTAvailableExecption.
I thought that may be cassandra is down. But when i have tried to send request to cassnadra by using DataStax driver . Running in a different System it is working fine. So now My question is that

When I am increasing the load on DataStax java driver it is Opening more connection instead of using existing connection. Why it is not using the existing connection?

2 Answers2

1

By default the driver should only have connections based on the number of nodes in the cluster (1 connection per node I believe). This makes me think that your issue is with your Jmeter code and not the Java driver.

In normal operation using the native protocol, the java driver sends multiple requests along each connection simultaneously so there is no need to open multiple connections to the same server. There is some work around upping the limit of simultaneous requests.

RussS
  • 16,476
  • 1
  • 34
  • 62
  • Hi Russ thanks for the reply but? How come it is possible My jmeter code is client and it is sending multiple request . At the server end its is Datastax java driver which is creating connection with the cassandra node. it is supposed to maintain one or two connection per node. But currently it is not doing that. I have used simple code for building Session object
    – soumyadeep sarkar Jul 24 '14 at 04:59
  • This is the code i have used for creating connection with the cluster
    ``public void connect(String node) { cluster = Cluster.builder() .addContactPoint(node) .build(); Metadata metadata = cluster.getMetadata(); System.out.printf("Connected to cluster: %s\n", metadata.getClusterName()); for ( Host host : metadata.getAllHosts() ) { System.out.printf("Datacenter: %s; Host: %s; Rack: %s\n", host.getDatacenter(), host.getAddress(), host.getRack()); } }``
    – soumyadeep sarkar Jul 24 '14 at 05:00
1

The connection was increasing Due to calling creating multiple session for each request. Now it is working Fine.

     builder = new Cluster.Builder().
            addContactPoints("192.168.114.42");

    builder.withPoolingOptions(new PoolingOptions().setCoreConnectionsPerHost(
            HostDistance.LOCAL, new PoolingOptions().getMaxConnectionsPerHost(HostDistance.LOCAL)));

    cluster = builder
            .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
            .withReconnectionPolicy(new ConstantReconnectionPolicy(100L))
            .build();
    session = cluster.connect("demodb");

Now Driver is maintain 17-26 number of connection irrespective of number of transaction.