Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 1.8.x

Connection Pools needed for Couchbase ?

1 reply [Last post]
  • Login or register to post comments
Tue, 12/11/2012 - 12:37
kkcheungus
Offline
Joined: 11/28/2012
Groups: None

Hello;

I am evaluating Couchbase and follow examples of the JAVA SDK to try out get and set with Couchbase.

To get a CouchbaseClient I use the method

//First I got a CouchbaseClient

couchbaseClient = new CouchbaseClient(URI_LIST,"default", "");

//Than I get some values form Couchbase
CASValue userAccountCASValue
= couchbaseClient.gets(usersAccountDocumentKey, USERS_ACCOUNT_TRANSCODER);

//Than I shutdown the couchbaseClient
couchbaseClient.shutdown(SHUT_DOWN_WAIT_TIME, TimeUnit.SECONDS);

Now in the real system, this is type of process is going to be done with very high concurrency, about 100K per second.

My question is,

is
couchbaseClient = new CouchbaseClient(URI_LIST,"default", "");
and the corresponding
couchbaseClient.shutdown(SHUT_DOWN_WAIT_TIME, TimeUnit.SECONDS);

Expansive to execute.

Should the CouchbaseClient be cached somewhere for reuse ?

In SQL database, creation of a connection is expansive and often there are connection pools to reuse
the connection.

Is there equivalent consideration for Couchbase ?

Will the high concurrent, creating and shutting down a CouchbaseClient a concern ?

Any pointers or reference to this matter will be most appreciated.

Top
  • Login or register to post comments
Wed, 12/12/2012 - 02:14
daschl
Offline
Joined: 05/19/2012
Groups: None

Hi,

thanks for raising this!

Actually its quite simple: Initializing the client takes time, so make sure to do it only once (or as less as possible). You don't need to have connection pools, because the client itself handles all connections for you (and they depend on the amount of servers you have in the cluster).

So, make sure to connect during startup (for example in a context listener on servlets) and reuse the connection. Since everything happens asynchronously, as long as you dont wait for the futures to finish, you can work with the client commands in a nonblocking fashion. A common pattern is to use a singleton object to return the connected instance (if you need a controlled way to share your object).

Does this answer your question or do you need any specific advise?

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