Too slow to connect to Cassandra cluster with datastax java driver 2.1.4 -


i have set cassandra cluster 2 nodes on 2 servers identical hardware configuration in same internal network recently. works cqlsh, seems perfect. followed code example in datastax's website write java code work cluster , problems comes. program works, connects cluster , writes , reads data it. however, connection way slow! deployed code in same machine 1 of cluster node resides , takes on 5 seconds connect. more precisely, it's line session = cluster.connect() takes of time.

i tried setup cassandra cluster 1 node in same network, similar hardware configuration. takes around 1 second connect. think it's missed configurations when writing code. spend quite time searching answer not any. given 5 seconds connection time, hard me consider use replacement current database.

in addition, ping time among these machines within 1ms, don't think it's network's problem. using cqlsh connect cluster fast too.

the cassandra version 2.1.4 , maven dependency datastax

<dependency>     <groupid>com.datastax.cassandra</groupid>     <artifactid>cassandra-driver-core</artifactid>     <version>2.1.4</version> </dependency> 

so wonder if enlighten me on why it's takes long connect cluster 2 nodes. thank much.

here code connect cassandra cluster , it's same shown in website.

    long start = system.currenttimemillis();     cluster = cluster.builder().addcontactpoint(node1).addcontactpoint(node2).build();     metadata metadata = cluster.getmetadata();     system.out.printf("connected cluster: %s\n",metadata.getclustername());     system.out.println(metadata.getpartitioner());      session = cluster.connect();     long time = system.currenttimemillis() - start;     system.out.println("time connect : " + time); 

i believe found reason why it's slow. it's because set rpc_address 0.0.0.0 in cassandra.yaml. once set ip address, connection time dropped 5 seconds 0.2 second.

is because rpc address affects node discovery time ?


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -