Blog Post

Client Libraries for Couchbase Server

Published

Couchbase Server is simple to develop for by it's very nature.  Modeling your data, as many of my colleagues often say, is simply a matter of organizing it like the natural world around you.  I know that seems like a blindingly straightforward idea, but many a software developer has had to deal with the impedance mismatch when building the software between the users and their data.   

When we set out to build Couchbase Server 1.8's predecessor, Membase Server, we had a really good handle on how people were doing this with large scale apps already.  Compatibility with memcached meant you could take an existing app, write a few negative lines of code (that means remove them, not write grumpy code!) and be up and running on Couchbase Server.

The magic for this was by proxying either client or server side with Moxi.  We already have such high throughput and low latency, that Moxi overhead is not noticeable in most deployments.

We had also developed a couple of clients that knew at their inner-hashing-algorithm-core how to find or store a piece of data.  The engineers in us said this was the pure way.  Many of our users agreed, and we'd often had requests about building smarter, but compatible, client libraries for other platforms.  If we were to do so we'd simplify even further by removing the pretty transparent, but still required layer of Moxi.

Starting today, we've made things even simpler and faster where the code meets the wire.

With the new release of Couchbase Server 1.8, we have a set of PHP, Ruby and C client libraries which know all about a cluster and how to work with it.  We kept to either exactly or almost exactly the same API.  This makes for simple upgrades to the new client library.  We didn't stop there though, we also invested in modern packaging, software distribution and better documentation for existing Java and .NET users.  We simplified and streamlined the website with software development in mind as well.  Please let me know what you think of it.

In his blog, John Zablocki introduces the new .NET SDK, while Rags Srinivas covers the updates in both the Java and Ruby SDKs.  Our own Jan Lehnardt also gives a quick rundown on the PHP SDK.  PHP and Ruby get their smarts from the brand new C (a.k.a. libcouchbase) SDK.  It's new from the ground up, and built for speed and portability.

Just to give one small example of what I mean, here is a sampling operations out of our Ruby client library built atop libcouchbase:

Loops is 5000
Small value size is: 19 bytes
Large value size is: 4189 bytes
                                 user     system      total        real
set: dalli                   0.640000   0.310000   0.950000 (  2.280556)
set: memcached               0.260000   0.180000   0.440000 (  1.741302)
set: memcached:buffer        0.070000   0.120000   0.190000 (  1.242726)
set: couchbase               0.220000   0.270000   0.490000 (  0.930583)

get: dalli                   0.660000   0.250000   0.910000 (  2.348882)
get: memcached               0.240000   0.390000   0.630000 (  2.859149)
get: memcached:buffer        0.290000   0.310000   0.600000 (  2.778201)
get: couchbase               0.260000   0.260000   0.520000 (  0.907956)

get-multi: dalli             0.910000   1.150000   2.060000 (200.106302)
get-multi: memcached         0.350000   0.720000   1.070000 (200.054008)
get-multi: memcached:buffer  0.350000   0.510000   0.860000 (200.028848)
get-multi: couchbase         0.210000   0.140000   0.350000 (  0.442803)

That shows execution time in both CPU and wall clock for a fixed workload.  Lower numbers are better, of course.  The code for the benchmark is in the ruby client.

I definitely respect the other clients and we still provide perfect compatibility for them through Moxi, but you can easily see that by adding some smarts we've been able to bring throughput up 150-200% (and much, much higher in one particular case).  It's not often you'll see that kind of speedup with mature software!

We've seen similar results from the PHP client library. I'm pretty sure it's going to be hot stuff for simplifying deployments and giving extra headroom in performance critical deployments

Please jump straight into the area that interests you, whether it's Java, .NET, PHP, Ruby or C.  There are also a few other experimental clients happening.  If you have any questions or feedback let us know on the forums.

Happy hacking!

p.s. I am serious about wanting feedback on the new site. Please let me know.