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 = "192.168.0.10";
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()
.keepAliveInterval(0)
.queryEnabled(false) // Wild guess to speed-up the processs
.build();
}
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:
@PostConstruct
public void initialize() {
state = States.BEFORESTARTED;
// Perform intialization
state = States.STARTED;
System.out.println("Service Started");
// Cluster and Bucket initialization
Persistence.getBucketInstance();
}
And last here is the current environment parameters that I use, maybe tuning them could yield better performance.
CouchbaseEnvironment: {
sslEnabled=false,
sslKeystoreFile='null',
sslKeystorePassword='null',
queryEnabled=false,
queryPort=8093,
bootstrapHttpEnabled=true,
bootstrapCarrierEnabled=true,
bootstrapHttpDirectPort=8091,
bootstrapHttpSslPort=18091,
bootstrapCarrierDirectPort=11210,
bootstrapCarrierSslPort=11207,
ioPoolSize=8,
computationPoolSize=8,
responseBufferSize=16384,
requestBufferSize=16384,
kvServiceEndpoints=1,
viewServiceEndpoints=1,
queryServiceEndpoints=1,
ioPool=NioEventLoopGroup,
coreScheduler=CoreScheduler,
eventBus=DefaultEventBus,
packageNameAndVersion=couchbase-java-client/2.1.3 (git: 2.1.3),
dcpEnabled=false,
retryStrategy=BestEffort,
maxRequestLifetime=75000,
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},
keepAliveInterval=0,
autoreleaseAfter=2000,
bufferPoolingEnabled=true,
queryTimeout=75000,
viewTimeout=75000,
kvTimeout=2500,
connectTimeout=5000,
disconnectTimeout=25000,
dnsSrvEnabled=false
}
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.