RYOW (read your own write) can be tricky with some of the NoSQL databases but not with Couchbase Server. With Couchbase Server active vbucket takes the writes and reads by default (though you can read from replicas if you like any time) and that means, in steady state, you can read your own writes… no problem! Couchbase Server writes to memory first and quickly replicated through DCP to replicas and persist to disk. You can wait for acknowledgements on replication or persistence when you issue an update. That ack gets you the same guarantee of RYOW even under a node restart or failover (a.k.a ReplicateTo and PersistTo flags).

When it comes to queries, unlike relational databases, Couchbase Server queries give you the option to either read what’s been processed in the view without waiting OR query can wait until all updates are processed, up to the point of the query request to ensure RYOW in the query. So first one is low latency and is referred to as a query with “stale=ok”. And later one is known as “stale=false” query that waits for processing, thus can be higher latency! Stale=false type queries are super useful. Imagine building a messaging app. If the message you sent does not appear in your “sent messages” folder (which is typically a view query), you may send it again! Or you save a new playlist in your mobile app, you go back to your playlists and if you don’t see that new playlist, you are confused! So stale-false is essential!

With that background lets take a look at how 3.0 improves the situation. For getting RYOW in earlier versions of Couchbase Server, you needed to do 2 things;

  1. your update need to use PersistTo flag
  2. your query need to use stale=false flag

That would get you RYOW in earlier versions like Couchbase Server 2.5. PersistTo obviously slows things down to disk speed. However with the streaming replication (DCP) + Incremental Map/Reduce Views, getting RYOW no longer require persistTo in Couchbase Server 3.0. Here what the same call looks like in 3.0. You no longer need #1 thus PersistTo.Zero.

The latency can be 50x lower in 3.0 compared to previous versions like Couchbase Server 2.5. That is great bang for the buck! If you are using views and need “stale=false” queries, Couchbase Server 3.0 will get you a great deal of benefits. Upgrade is easy and online. You can download 3.0 here.

Happy testing.


Posted by Cihan Biyikoglu, Director of Product Management, Couchbase

Cihan Biyikoglu is a director of product management at Couchbase, responsible for the Couchbase Server product. Cihan is a big data enthusiast who brings over twenty years of experience to Redis Labs’ product team. Cihan started his career as a C/C++ developer.

Leave a reply