Couchbase as memcached replacement – find out expiration time of your keys

www.esl.eu is making heavy us of the memcache daemon as an indispensable caching layer. It is very simple and rockstable. Our servers have an uptime of currently 412 days. And thats only because we had to move our racks to another datacenter. But theres some big downsides of memcached. It does not scale, has very few statistics to determine performance problems and no automatic failover mechanics.

So about a year ago for me “nosql” was the new buzzword. Pretty much reminded me of memcached in the first place. Some research brought up couchbase with a 100% compatible memcached api. So we started to try that out. Felt pretty stable and the installation was painless. They provide a debian package which was puppetized in no time. A few month in development stage we made the decision to give it a try in production.

Now we are transitioning our memcached cluster to a couchbase cluster. Our production cluster is starting with 5 nodes with each 16 GB RAM and SSD backed. In this transition phase we are letting our memcached class write both stores; the still active memcached cluster and additionally in our new couchbase cluster. We are gathering performance statistics and its the first time we are able to see really lots of stuff which memcache was not providing. For example the total number of items in the cache. (correction total numbers are actually listed) but to make it short: memcache does not provide stats like these

The big difference between memcached and couchbase is its purpose. memcached is meant a caching layer, couchbase is a key / value database. Where for memcache it is ok to evict keys, a database should never lose data. So thats why couchbase needs a disk backend to persist data. This on the other hand makes you care about TTL times on your keys. If you have no TTL set, couchbase will store them forever and will end up being blocked by no space left on device.

Heres a little couchbase view to find out how many and which keys have no expiration set in your couchbase bucket.

1
2
3
4
5
function (doc, meta) {
if (meta.expiration == 0) {
emit(meta.id, meta.expiration);
}
}

if you want the total count of the items just add the built-in reduce function called _count. Make sure to apply the view on the full data set to get real numbers.

I will share more expierence with couchbase over time.

Author: Thomas Poehler

Tags: , ,

  • Diez

    but memcached provides the total number of items!

    • tommics

      you are right. While writing I was not sure if thats in the telnet stats. So shame on me for missing verification. Will remove that part.

  • Irinel Bucur

    do you have new information about this? how it is the speed when you try to get a value from couchbase vs memcache? we are in the same position like you and we try to switch to couchbase but, I am a little not convinced it is going to be the right choice since we have more than 100k get requests per second from only one machine and it is going to increase more. the benchmarks i’ve seen shows me with many concurent gets there is a lower performance.