Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

Connection pooling in Couchbase SDK (spymemcached)

4 replies [Last post]
  • Login or register to post comments
Wed, 10/10/2012 - 16:54
GauravShah
Offline
Joined: 10/10/2012
Groups: None

Hi,

We are in process of evaluating couchbase. Following are the list of questions with reference to couchbase.
1) Does the couchbase client has internal connection pooling ocncept ? If yes, how can we tune the connection pool ? If not, can someone provide a sample code to write custom code.
2) CouchbaseClient is thread-safe. How many concurrent thread it can serve ? What is the upper limit for no of thread accessing the client object concurrently ?

Regards,
Gaurav Shah.

Top
  • Login or register to post comments
Thu, 10/11/2012 - 11:02
GauravShah
Offline
Joined: 10/10/2012
Groups: None

Sorry for typos.

We are in process of evaluating couchbase. Following are the list of questions with reference to couchbase.

1) 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 ?

2) 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 ?

Regards,
Gaurav Shah.

Top
  • Login or register to post comments
Mon, 10/15/2012 - 07:25
rags
rags's picture
Offline
Joined: 12/29/2011
Groups: None

Gaurav:

Connection pooling is not required. You can tune some of the parameters in the Couchbase connection, however,
via the CouchbaseConnectionFactoryBuilder class. Please refer to

http://www.couchbase.com/wiki/display/couchbase/Couchbase+Java+Client+Li...

Yes, the CouchbaseClient is thread safe. There is no upper limit from a Couchbase connection perspective.

Thanks!

Rags

Top
  • Login or register to post comments
Mon, 10/15/2012 - 15:15
GauravShah
Offline
Joined: 10/10/2012
Groups: None

Thanks Rags for the reply .... !

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.

Regards,
Gaurav Shah.

Top
  • Login or register to post comments
Tue, 10/16/2012 - 07:42
rags
rags's picture
Offline
Joined: 12/29/2011
Groups: None

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.

Thanks!

Rags

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker