Our company use Couchbase server 3.1.3 with java client version 1.3.1.
I was asked to upgrade to Couchbase server 6.5 with java client 2.7.13. The code changes was simple.
However, the load test(Jmeter) result showed the response time was about 10% to 15% slower compared with our old version.
I created some simple java programs for both 1.3.1 and 2.7.13. They bypassed the application server and went to couchbase server directly. The code is very simple. It initialized the couchbase environment and then call the “get” method to retrieve document. It run multi threads concurrently with a given duration. At the end of execution, it print out how many “get” method was called. The code snapshot is like:
For java client 1.3.1
main function —
List nodeList = new ArrayList<>();
nodeList.add(URI.create("–url–"));
CouchbaseConnectionFactoryBuilder builder = new CouchbaseConnectionFactoryBuilder();
connectionFactory = builder.buildCouchbaseConnection(nodeList, “–bucket name–”, “–password–”);
couchbaseClient = new CouchbaseClient(connectionFactory);
ExecutorService executor = Executors.newFixedThreadPool(threads);
for (int i = 0; i < threads; i++) {
list.add(new TestRun());
}
List<Future> futures = executor.invokeAll(list);
long total = 0;
long failed = 0;
for (Future f : futures) {
total += f.get();
}
public static class TestRun implements Callable {
@Override
public Count call() throws Exception {
int counts = 0;
long start = System.currentTimeMillis();
String doc = “”;
while (true) {
long end = System.currentTimeMillis();
if (end - start > duration) {
break;
}
String key = getKey(end);
doc = (String) couchbaseClient.get(key);
counts++;
}
return counts;
}
}
For java client 2.7.13
main function —
Builder builder = DefaultCouchbaseEnvironment.builder();
env = builder.build();
List nodeList = new ArrayList<>();
nodeList.add("-- url --");
cluster = CouchbaseCluster.create(env, nodeList);
cluster.authenticate("-- user name --", “-- password --”);
bucket = cluster.openBucket(“bucket name”);
ExecutorService executor = Executors.newFixedThreadPool(threads);
for (int i = 0; i < threads; i++) {
list.add(new TestRun());
}
List<Future> futures = executor.invokeAll(list);
long total = 0;
long failed = 0;
for (Future f : futures) {
total += f.get();
}
public static class TestRun implements Callable {
@Override
public Integer call() throws Exception {
int counts;
long start = System.currentTimeMillis();
RawJsonDocument doc = null;
while (true) {
long end = System.currentTimeMillis();
if (end - start > duration) {
break;
}
String key = getKey(end);
doc = bucket.get(RawJsonDocument.create(key));
counts++;
}
return counts;
}
}
I tried the following couchbase servers
couchbase-server-community-4.5.1-centos7.x86_64.rpm
couchbase-server-community-5.1.1-centos7.x86_64.rpm
couchbase-server-community-6.0.0-centos7.x86_64.rpm
Java client 1.3.1 version of the test program’s performance is better than my Java client 2.7.13 program. Can anyone tell if I missed any important steps. By the way, I only had one node during the test.