mike.cheng avatar image
mike.cheng asked Erick Ramirez answered

Is session establishment taking longer in Java driver 4.x?

We recently upgrade the java driver from 3.x to 4.4 and wonder if the session establishment takes longer. When having single-node C* cluster and client on the same machine, the elapsed time for

is around 2-3 seconds. When we deploy multi-node cluster and client on GKE, the elapsed time may be longer although we don't see any warning logs printed by the driver. Based on our experience, we think the driver 4.4 takes longer than the driver 3.x.

Can you share your benchmarks to help us tell whether such time is reasonable or any suggestions on how we can troubleshoot or further optimize the connection time? Any feedback is appreciated!

java driver
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

steve.lacerda avatar image steve.lacerda ♦ commented ·
Do you have any logs or traces showing the session establishment comparing 4.x to 3.x? We don't have any open issues that I'm aware of here. What version of 4.x also?
0 Likes 0 ·
mike.cheng avatar image mike.cheng steve.lacerda ♦ commented ·

We use 4.4. When I set the log level to FINE, I saw more logs but did not provide much information. I would like to know what is the reasonable elapsed time range when is called.

0 Likes 0 ·
steve.lacerda avatar image steve.lacerda ♦ mike.cheng commented ·
There are a ton of factors, like number of nodes, schema (so number of tables), network time, client latencies, etc. With that said, I've seen anywhere from 2-14s. You should be able to tell from the logs though where the time is primarily getting spent.
0 Likes 0 ·

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

When you first start your app, the driver goes through an initialisation process which includes establishing a control connection to the first node it manages to contact (from the contact points list). In this phase, the driver uses the control connection to:

  • query the system.peers table to discover the cluster topology
  • query the system tables to get schema metadata
  • check for schema agreement across the cluster

There are no benchmarks or expected duration because the time it takes for a driver to establish connection to a cluster depends on a lot of moving parts which include (but not limited to):

  • network latency
  • cluster topology - number of nodes, data centre configuration
  • cluster load - busy nodes take longer to respond
  • schema - number of tables across all keyspaces have a significant impact

If you enable tracing, you should be able to work out from the timestamps where the initialisation spent most of its time. Cheers!

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.