Question

Official couchbase documentation says.

"If you already have an application that uses the Memcached protocol then you can start using your Couchbase Server immediately. If so, you can simply point your application to this server like you would any other memcached server. No code changes or special libraries are needed, and the application will behave exactly as it would against a standard memcached server. Without the client knowing anything about it, the data is being replicated, persisted, and the cluster can be expanded or contracted completely transparently."

We already have a C based application which was working with memcached by using libmemcached C APIs. We wanted to move to couchbase since we wanted persistence (mainly). We saw the aforementioned Couchbase quote and tried this (with Couchbase bucket) and it was a pleasant surprise. It worked , just like that. +1 for that.

We found that there also exists a Couchbase C api, Now following are the questions,

  1. If libmemcached API is enough to use Couchbase, what does the Couchbase C API offer ?
  2. What are the disadvantages of ( continuing ) to use (existing ) libmemached API to talk to Couchbase type bucket of Couchbase server ?
  3. What are the advantages of upgrading our application to use Couchbase C api to talk to Couchbase server ?
Was it helpful?

Solution

1) If libmemcached API is enough to use Couchbase, what does the Couchbase C API offer ?

Of course couchbase extends memcached protocol with new operations, like touch, observe, get with lock, unlock, read from replica etc. Some of them although can be implemented in libmemcached (I've done patch for touch command a while ago), not supported by the vanilla memcached server, therefore it will be harder to test and maintain in libmemcached. Other commands like observe, read from replica, cannot be implemented in terms of libmemcached at all. Another group of APIs of Couchbase is view queries to database indexes, which built with map/reduce, libcouchbase is able to do it.

2) What are the disadvantages of ( continuing ) to use (existing ) libmemached API to talk to Couchbase type bucket of Couchbase server ?

Libmemcached, like any other memcached client you can find, considered as "dumb" or "legacy" client, as opposed to "smart" clients. The difference is whether or not the client aware of cluster topology. Legacy clients have to go through single entry point in the cluster or do some kind of balancing (like round-robin). And by default it will use server-side proxy for that, which aware of topology and can re-route in case that this node doesn't own the key. Therefore you will likely hit the limit of this proxy, when network/CPU/memory capacity actually enough to serve requests (although it is possible to setup this proxy on client side). The smart clients aware of the cluster topology and follow its change, so that it can eliminate re-routing of the keys.

3) What are the advantages of upgrading our application to use Couchbase C api to talk to Couchbase server ?

You will be able to access other APIs and extended API of memcached. Also Couchbase clients can optimize network usage.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top