We are in process of evaluating couchbase. Following are the list of questions with reference to couchbase.
Does the couchbase client has internal connection pooling concept ? If yes, how can we tune the connection pool ? If not, can someone provide a sample code to develop connection pooling ?
It is mentioned that CouchbaseClient is thread-safe.
How many concurrent thread it can serve ? What is the upper limit for thread pool for accessing the client object concurrently ?
I was looking into code implementation and notice that couchbase makes a single SocketChannel connection to server (node). I mean one SocketChannel connection per node.
While referring to javavdoc of SocketChannel, it specifies that :
Socket channels are safe for use by multiple concurrent threads. They support concurrent reading and writing, though at most one thread may be reading and at most one thread may be writing at any given time. The connect and finishConnect methods are mutually synchronized against each other, and an attempt to initiate a read or write operation while an invocation of one of these methods is in progress will block until that invocation is complete.
I inferred this statement as all the request to the server are queued up and one single socket connection is made and then sequentially requested is served. i.e. one at a time.
Lets take a scenario either my network is slow or the amount for request generated during bulk load / bulk access is too high as compare to the rate at which it is served. The requested is queued up at couchbase client level (ReadOperationQueue,WriteOperationQueue,OperationQueue, etc) followed by requested queued up at SocketChannel level.
Coming back to my original question, do we require custom connection pool in order to create multiple socket connection to same server. Only concern is that we are making only one physical socket connection with server thus wanted to understand that will it cause a bottleneck or not.
Kindly point out in case my interpretation is incorrect.
Connection pooling is not required. You can tune some of the parameters in the Couchbase connection, however,
via the CouchbaseConnectionFactoryBuilder class. Please refer to
You are right about the internal workings of the Java client library. These operations are meant to be low latency operations and since they are asynchronous in nature the queueing should not be an issue. So, still of the opinion that connection pooling is not required.