Slow initial requests


Hi, I was wondering if I could improve the following situation. Currently I created a single static cluster instance and a single static bucket and I reuse both as suggested by the documentation. The problem is that I find the initial connection a bit slow and bulky and since this drastically affects redeploys I would like to speed up the process.

So in a nut shell what I see is that each time I redeploy my java server restarts very fast but it takes about ~10 seconds to initialize Couchbase cluster and connect to the bucket, and the connection time remains the same regardless of the size of the bucket. Ideally I would like this to be as fast as possible, maybe I’m missing something or perhaps I could tune the default cluster environment to speed the process up but I don’t know which parameters to tune.

Here is the code I use to initialize the cluster and the bucket.

public class Persistence {

  //Couchbase Configuration
  private static final String clusterAddress = "";
  private static final String bucketName = "BucketTest";
  private static final String bucketPassword = null;

  private static CouchbaseEnvironment environment;
  private static Cluster cluster;
  private static Bucket bucket;
  public static Bucket getBucketInstance() {
    if (environment == null) {
      environment = DefaultCouchbaseEnvironment.builder()
              .queryEnabled(false)         // Wild guess to speed-up the processs
    if (cluster == null) {
      cluster = CouchbaseCluster.create(environment, clusterAddress);
    if (bucket == null) {
      bucket = cluster.openBucket(bucketName, bucketPassword);
    return bucket;


I also auto initialize this during server start-up:

  public void initialize() {
    state = States.BEFORESTARTED;
    // Perform intialization
    state = States.STARTED;
    System.out.println("Service Started");
    // Cluster and Bucket initialization

And last here is the current environment parameters that I use, maybe tuning them could yield better performance.

CouchbaseEnvironment: {

packageNameAndVersion=couchbase-java-client/2.1.3 (git: 2.1.3), 
retryDelay=ExponentialDelay{growBy 1.0 MICROSECONDS; lower=100, upper=100000},
reconnectDelay=ExponentialDelay{growBy 1.0 MILLISECONDS; lower=32, upper=4096}, 
observeIntervalDelay=ExponentialDelay{growBy 1.0 MICROSECONDS; lower=10, upper=100000}, 


Also I’m using WildFly as a JavaEE server, and Couchbase is running on a separate machine under linux both on the same LAN with the following versions, Couchbase 3.0.3-1716 Enterprise Edition (build-1716) and Couchbase client 2.1.3.

Any ideas of how could I speed this up, or what could I be doing wrong¿?

As always thx in advance.


Just to check I updated Couchbase java client to 2.2.1 to see if there was a performance improvement, then I realized this message:

DNS Reverse Lookup of is slow, took 4512ms

so there’s 4.5 seconds I know I’m wasting, but I don’t understand why since I’m not resolving any hostname, I’m using IP (as String) as you can see on the above code. Any hints of what can I change to speed up the DNS lookup or force IP connection? That would leave the issue under ~5s and I’m sure I can disable things in the cluster environment to push that number even lower.

:slight_smile: as always thx in advance.

EDIT Ohhh my… sorry for the duplicated question, I’ve just seen this JavaClient 2.x connection`s warning, but still I’m looking for the environment tuning part.*


@Lethe we are doing a DNS reverse lookup since we convert the string into an InetAddress later on.

The proper way to fix is on your operating system, make sure that reverse DNS lookup works properly (so your IP address maps to the right hostnames). This should normally take a few milliseconds at most.


I finally tested, the new setup, I didn’t like the idea of modifying the host file of all the machines so I ended up implementing a host override on our DNS server which all our machines use.

One interesting fact is that, although the warning estimated 4512ms of the total of 10 seconds to initialize that I calculated, after changing the setup so that host-name is used instead of an IP, the total time to initialize Couchbase is now under 2 seconds, and according to calculations I should be expecting more or less 5 seconds, so that’s amazing and resolves the issue of needing to disable parts on the cluster environment to speed up.

Thx @daschl

One last thing, I would love to see in future versions of Couchbase the ability to use IP over hostname as a cluster environment option, since although DNS are good and can be use to avoid hardcoded IP or even used as a fallback, accessing through IP would always be safer, simpler and faster IMO, things can go messy with hostname resolution when using VPN, or simply a complex network.

Once again thx.


@Lethe hm, we’d need to investigate but the problem itself lies in the InetAddress class which performs those reverse DNS lookups on our behalf. Maybe we can build a wrapper or something, but its not a trivial change.


anyways, glad your issue is solved now!