How to Improve the Performance of Couchbase in a Single noded Environment?

Currently We have a XML database as an existing database in our application. we want to migrate to NOSQL database, So
we are checking the performance of Couchbase and MongoDB. I have read that Couchbase is faster than MongoDB in some of the Technical forms of couchbase but When I compare the performance of MongoDB with Couchbase, Mongodb performance is better than Couchbase.

Note: I have only Checked the performance Read operation in Single Database Server(Single Node Environment).

Environment:
Installed Couchbase: couchbase-server-community_4.0.0-windows_amd64
Java_SDK(Client): Couchbase-Java-Client-2.2.8 (Contains: rxjava-1.0.17.jar, couchbase-java-client-2.2.8.jar, rxjava-1.0.17.jar)

OS Version: Windows7 - 64 bit
RAM: 8GB
HD: 500GB

Please find the following code for insertion and Retrieval:

Inserting:

String finalData = “{“device”:{“y”:{“devicesmsPropertyList”:{“dskFlag”:“false”,“serialId”:1000,“inputTray”:{“LIST”:{“e”:[{“inTray”:{“id”:“1” etc…}}}}”;

JsonObject infoObj = JsonObject.create().put(“deviceinfo”, JsonObject.fromJson(finalData));

bucket.upsert(JsonDocument.create(“device” + i, infoObj));

Fetching:

// Create a N1QL Primary Index (but ignore if it exists)
bucket.bucketManager().createN1qlPrimaryIndex(true, false);

List list = new ArrayList<>();
N1qlQueryResult result = bucket.query(N1qlQuery.simple(“SELECT deviceinfo.device.deviceId, ipAddress,deviceinfo.device.noResponse,deviceinfo.device.deviceImageUrl,deviceinfo.device.createTimestamp,deviceinfo.device.deviceImageWidth,deviceinfo.device.deviceImageHeight,deviceinfo.device.communicationResult, deviceinfo.device.y, deviceinfo.device.latestInfo.smsProperty.timestamp FROM default LIMIT 30;”));

        for (N1qlQueryRow row : result) {

            list.add("{\"device\":" + row + "}");
        	
        }


// Sending  list to the browser to display.

I am using the same configuration and datamodel for both Mongodb and Couchbase.

Please let me know If I am missing anything while inserting or Fetching into/from the Bucket of Couchbase.

@pioneer.suri,
20% Slowness as compare to MongoDB
:wink:

Thank you @egrep, I had a chance to look into the provided link but they are also facing the same problem with the performance. I am expecting the suggestions from the couchbase team to improve the performance of couchbase by doing some configurations.

I have posted my code snippet for inserting and fetching. Please guide If I can do any optimizations while fetching to improve the performance.

It would be useful if you could provide some quantitive measurements for the insert time and query time.

Note that is appears that you’re basically reading most (all) of the fields of your documents, without any WHERE clause - is this a representative example of how you’re application operates?

If you know the key of the document you’re interested in, fetching the whole document (via bucket.get() - see Couchbase SDKs) is likely to bring much better performance.

Finally if you’re planning on using Enterprise Edition in your deployment I’d recommend testing with 4.5 - this has a number of performance improvements, and also allows fetching a specific set of fields from a document with the Sub-document API

Hello @drigby, Thank you for considering my request.

It would be useful if you could provide some quantitive measurements for the insert time and query time.

Ans: Currently I am not measuring the time for insertion, Mostly I was looking for fetching the data after inserting the data using sample program.
Please find the below quantitative measures.

For 4.07 MB data, Couchbase is taking 139 MS time - Fetching all the data(select *)
101 MS time - Fetching the required data(select col1, col2…)

Please correct If my assumption is wrong in showing the data size from the attached image.

Note that is appears that you’re basically reading most (all) of the fields of your documents, without any WHERE clause - is this a representative example of how you’re application operates?
Ans: In the real time application we will be having the WHERE condition but to check the performance, we are not using any filters(WHERE). Even we have not used WHERE condition with Mongodb also.

If you know the key of the document you’re interested in, fetching the whole document (via bucket.get() - see http://docs.couchbase.com/developer/java-2.0/documents-retrieving.html) is likely to bring much better performance.

Ans: As per measurements given for First thing I have checked it by using "SELECT * ", Is there any difference we can find If We use bucket.get(“key”) in terms of performance?

Finally if you’re planning on using Enterprise Edition in your deployment I’d recommend testing with 4.5 - this has a number of performance improvements, and also allows fetching a specific set of fields from a document with the Sub-document API

Ans: Currently we planned to use Community Edition, If we can find lot of performance improvements by using Sub-document API (4.5), We may go for Enterprise Edition.