Need to know how is the replica resident ratio calculated
Couchbase shards the dataset into what we call vbuckets, and these are themselves containers of data (individual key/value stores). A vbucket itself is labelled as active or replica.
In all buckets there will be 1024 active vbuckets and then the replica count depends on your replica configuration, so if replica=1 you have 2 copies of every key/value and a total of 2048 vbuckets.
Each vbucket is a key/value store and knows the total number of keys that exist and how many of them are in the memory hash-table (each vbucket has its own hash-table).
Thus to calculate the replica resident ratio, we just need to query all data nodes and ask them to calculate the ratio of documents in memory where the vbucket is labelled as a replica.
Kindly let know if we have any documentation/article specifying as to how the memory allocated to a bucket is split to store its active and replica copies of the data,
The memory of a bucket isn’t itself “split”. If your bucket quota is 32GB, each node in the cluster will work with 32GB. The vbuckets will all share this quota.
Every bucket has 1024 active vbuckets and then for every replica you have configured adds 1024 more vbuckets.
The total vbuckets are distributed amongst your cluster nodes, so replica=1 and 4 nodes means 512 vbuckets per node (256 active, 256 replica).
If your memory quota is 32GB, each node will then consume upto 32GB of memory and the 512 active/replica are just sharing this quota.
If the bucket on a node reaches the bucket quota, we will begin paging items out of memory (reducing the resident ratio). The algorithm for paging prioritizes the active data, so you should end up with a active resident ratio which is greater then the replica one. Although I can’t provide an exact figure/function as there are many factors involved in deciding what can be paged out.
There’s more detail here Memory | Couchbase Docs