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.
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.