It is very slow to get a value for the first time after restoring

I was using an old version (2.5) of couchbase, and I decided to migrate to the latest version (7.1) on a new server. I used cbbackup and cbrestore to transport the bucket data.

The problem is my key-value-get operation takes more than 10ms for the first time a key is accessed. I only do key-value operations in my project. I have also tried the latest backup and restore system, but it’s not help. Is there any way to optimize this?

Hi geniuszxy,

The type of backup and restore should not affect the performance of data access. It sounds like the bucket has a low resident percentage (i.e. the percentage of documents that can be held in memory at one time).

If the document had been ejected from memory due to memory quota limitations then it will have to be retrieved from disk, which depending on the speed of disk, could take multiple milli-seconds.

Also document retrieval can be impacted depending on whether the bucket is configured for value eviction (where all the keys are maintained in memory) or full-eviction (where both the key and corresponding document are eligible for ejection from memory).

Therefore to achieve higher retrieval performance, you should use value eviction and set the bucket quota such that all the documents can be held in memory. This does assume you have sufficient physical memory on the underlying machine to set the bucket quota large enough.

Hope that helps!

The 3.x SDKs connect to the cluster asynchronously, and if only the very first KV operation is slightly slower, it could be because it’s including that initial bootstrapping.

You can add this after creating the Cluster and/or Bucket objects, to force waiting for the bootstapping at that point: