ClusterEnvironment creation very slow! Taking 5-6s

When initializing the Couchbase connection, creating a ClusterEnvironment takes 5-6 seconds. Even if I remove config options there is still a substantial delay in the initial connection that together with 3-4s for the cluster connect and bucket open statement causes the first request to take +10s.

Is there any way to optimize this? From what I’ve read ClusterEnvironment creation should be instant. I’m still learning about Couchbase so any help and input is welcome. Thank you!

Couchbase Java SDK 3.6.2
Couchbase Server 6.6.6

    ClusterEnvironment clusterEnvironment = ClusterEnvironment
        .builder()
        .timeoutConfig(e -> {
          e.connectTimeout(Duration.ofSeconds(10));
          e.disconnectTimeout(Duration.ofSeconds(5));
          e.kvTimeout(Duration.ofSeconds(5));
          e.queryTimeout(Duration.ofSeconds(30));
        })
        .ioConfig(e -> {
          e.enableDnsSrv(false);
          e.tcpKeepAliveTime(Duration.ofSeconds(4));
        })
        .build();

From what I’ve read ClusterEnvironment creation should be instant

The code that you are showing - ClusterEnvironment.builder()…build() should be instant - it’s just building an object. If that is taking a time - your jvm or machine itself is likely oversubscribed.

From the connect to the first operation on the bucket (this is when all the connections are made) will indeed take time depending on network latency. You can take thread dumps while it is occurring to see what is executing (kill -3 ). In other cases like this - the culprit has been DNS resolution.

The same issue happened to me. No one seems to acknowledge this. This code give people false impression that it would run instantly.
There’s some static init block which scanning all the jar files to retrieve MANIFEST_INFOS, which take 4-5s to complete. I post this in another thread here

1 Like

The same issue happened to me. No one seems to acknowledge this.

I opened a ticket - Loading...

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.