Using couchbase as a caching layer

Hi All,
When we use Couchbase server as a caching provider for a caching solution what specific configurations should be done/focused when setting up a bucket in couchbase server for caching?

Let me put the question in another way.

Lets say I already use couchbase server as the data store for a springboot or nodejs based micro service.Can I use plugins like couchbase-spring-cache and further improve the performance of already couchbase backed service?

Or you are recommending couchbase as a cache layer for services which are lacking performance and backed my RDBMS like postgres my sql?


According to this document you can use couchbase with default configuration in caching implementations leveraging memory first behaviour.IF default configuration is the way to implement caching using memory reads and writes how couchbase recover from a failure.In mongodb there is journalfile to refer to recover from failure.Does couchbase get similar approach to recover from failure when memory first write nodes failed?

Please clarify.

Thanks
Isuru

@shivani_g can you please assist ?

Hello @iisuru,

There is a fair few questions here, let me break them down:

When we use Couchbase server as a caching provider for a caching solution what specific configurations should be done/focused when setting up a bucket in couchbase server for caching?

This really depends on the use case and what the performance of the underlying data store. I would say the big question here is what bucket type to use: Couchbase Bucket or ephemeral. Our documentation covers the differences between the two. For a cache usecases Couchbase Bucket protect against cold cache situations. Where Ephemeral buckets have a reduce TCO as everything is stored in memory, saving the need for disks. Depending on the ejection policy used it will automatically removed old items when the bucket is full, making it easier to use as a cache.

Lets say I already use couchbase server as the data store for a springboot or nodejs based micro service.Can I use plugins like couchbase-spring-cache and further improve the performance of already couchbase backed service?

When the data store is Couchbase Server in most cases it makes no sense to put another Couchbase Cluster in front of it as a cache. It just makes the overall system more complex. Couchbase Server combine the Database and Cache all in one solution so in this case it makes sense just to increase the size of the existing cluster.

Or you are recommending couchbase as a cache layer for services which are lacking performance and backed my RDBMS like postgres my sql?

This is a very common use case for Couchbase Server, which in a number of case leads to Couchbase Server replacing the RDBMS in the long term. Why have two system, when you can have one that does both?

According to this document you can use couchbase with default configuration in caching implementations leveraging memory first behaviour.IF default configuration is the way to implement caching using memory reads and writes how couchbase recover from a failure.In mongodb there is journalfile to refer to recover from failure.Does couchbase get similar approach to recover from failure when memory first write nodes failed?

Couchbase Server provides complete flexibility when it comes to ensuring the data is safe. By default Couchbase Server will response when the 1st nodes has the data in memory. It will then asynchronously send the data to the replicas and write it to disk. For use cases that needs more protection, the application can ask for the write to only be successful once the data has been committed to disk or replicated to one or more nodes in memory or even committed to disk on multiple nodes. For more details please see durability.

1 Like

Thanks @pvarley for the detailed reply.
@pvarley @shivani_g
What is the most commonly used bucket type for cache implementation?Is it ephermal or couchbase?

In ‘couchbase’ bucket type you will get the freedom of keeping the memory limited and use the persistent storage to save some of the infrequently used cached data.
You need to worry about the recovery in 'ephermal ’ type only when all the data nodes are crashed since data is stored in sharded fashion in data service nodes that node failures are leading to auto resharding and rebalancing. Since all data node failures are unlikely given that n is sufficiently large do we need to bother about couchbase bucket type when implementing caching?

If not what additional advantages you get when u use couchbase type ahead of ephermal type while implementing caching?

Also I see you need only data service nodes in the cluster when you implement a cache with couchbase or ephermal type?Do you find scenarios where you need index ,query ,fts nodes etc are needed apart from data nodes while you implement cache with couchbase or ephermal type?

Please clarify.
Thanks
Isuru

What is the most commonly used bucket type for cache implementation?Is it ephermal or couchbase?

I would say this is current a Couchbase Bucket type but that is mainly because Ephermal buckets were only added in recently.

You need to worry about the recovery in 'ephermal ’ type only when all the data nodes are crashed since data is stored in sharded fashion in data service nodes that node failures are leading to auto resharding and rebalancing. Since all data node failures are unlikely given that n is sufficiently large do we need to bother about couchbase bucket type when implementing caching?

Indeed this is the advantage of using the Ephemeral bucket with the reduce TCO as there is no need for fast disks. That said the finally decision should be down to your use case. If you between that a full cluster restart is unlikely in the environment and if there was one the underlying data store can handle the load when the cache is being rebuilt then Ephemeral is a good choose.

If not what additional advantages you get when u use couchbase type ahead of ephermal type while implementing caching?

It covers the cold cache situation I mentioned. Also Couchbase buckets can use both Standard Index Storage and Memory Optimized Index Storage where only the latter can be used with Ephemeral.

Also I see you need only data service nodes in the cluster when you implement a cache with couchbase or ephermal type?

This is correct only Data Service nodes are needed.

Do you find scenarios where you need index ,query ,fts nodes etc are needed apart from data nodes while you implement cache with couchbase or ephermal type?

Yes some user like to query their cached, other users use it as means to use Couchbase Server to replace the underlying data store all together. Why manage two different systems when you can manage one.

If entire cluster failure is preventable can we rely on auto resharding and auto fail over of couchbase with ephermal buckets without sacrificing performance,scalability and robustness upon 1 or more node failure in the cluster at any larger data loads?So we can entirely get rid of couchbase bucket type?Or do we need to conduct load tests and figure out tipping point of ephermal couchbase bucket based cache recovery on few node failures?

Also could you please brief about the warmup strategies we can use with both ephermal and couchbase bucket types ?

Conversely I see "Limiting memory consumption " to achieve cost reduction as a viable reason to use “couchbase” bucket type ahead of “ephermal” type since disk consumption can be controlled via TTL flags for entities.

Please clarify
Thanks

So we can entirely get rid of couchbase bucket type?Or do we need to conduct load tests and figure out tipping point of ephermal couchbase bucket based cache recovery on few node failures?

It really depends on the use case, if you are happy that whole cluster failure is preventable or there is a completely different DR site. With regards to load testing and Ephemeral Buckets, the key point to be aware of is sizing, How many documents can be store in the bucket, how big does the cache have to be.

Also could you please brief about the warmup strategies we can use with both ephermal and couchbase bucket types ?

With Couchbase Bucket as everything is persisted to disk, when there is a whole cluster restart (which is extremely rare but normally caused by a DC wide issue) When Couchbase Server starts it will pull the documents of disk into memory. See the documentation for more detail on warmup.

For ephemeral buckets when it the whole cluster is restarted the bucket will be empty. It will be up to the application to warm up the bucket/cache. During that time the underlying data store will have additional load. It would be good to test this situation with the whole stack.

Thanks @pvarley.It has been a loud and clear explanation for an open ended topic.

Regards,
Isuru