How to Calculate Max Cache Size

Memory planning is important for setting up NCache. An easy estimate of the amount of memory your servers would need and how much of that memory needs to be allotted to NCache will be the main focus of this tip. There are two main variables that need to be calculated for this process. The first one is peak traffic load that you might see in you environment (estimated) and the second being the average item size being cached.

As an example if you have 100,000 requests at peak time and on average 50kb object size, than you can calculate the size of live data as below:

100,000 * 50KB = 5 GB

This (5GB) will be the amount of memory that you will allocate to the cache cluster through the NCache Manager and this is what you need to set as the Cache Max Size. Now that you know the size of data you need to put into the cache, the amount of required physical memory depends on the caching topology that you use.

Partitioned Replica Topology

In partitioned-replica topology, live data will be divided among the number of servers you have. So for each server, the amount of data will be: estimated_data_size / total_number_of_servers. If you have only 2 servers then this brings the per server memory cost to 2.5GB for live data only.

Since each server hosts a passive replica of some other server too, therefore, the required memory is doubled. Hence, increasing the per server memory cost to 5GB

Partitioned Topology

The data will be divided again between the active servers in the cache cluster. So the amount of data will be: estimated_data_size / total_number_of_servers. If you have 2 servers then this brings the per server memory cost to 2.5GB

Replicated Topology

For replicated topology, each server hosts all the data. This data is not divided amongst the servers. So each host server will need to have enough memory for caching 5GB of data

Calculating Overhead

After calculating the size of live data, you need to add 25% more of the calculated memory for the .NET over head. We recommend that you keep a buffer of another 2GB. Taking the example of Partitioned-Replica topology, this would sum up to:

5GB (Cached data) + 1.25GB (25% .NET overhead) + 2GB (Buffer) = 8.25GB

Now, add another 2 GB for OS and other applications which make this a total memory requirement of 10.25GB, which means that approximately 11GB is required.

This would give you a fairly accurate estimate of the physical memory size you require for the system.

How to Set the Cache Max Size

From the NCache Manager, left-click on the cache cluster to open the settings. Under the Main tab there is an option to set the Cache Max Size. You can set the value based on the above suggestions. After setting a memory limit that suits you needs, right-click on the cache cluster and select either Apply Configurations or Hot Apply Configurations to make sure that these settings are saved properly.

Since the Cache Max Size can be applied when the cache cluster is running as well as when it is stopped, so you can change this setting anytime without having to stop the cache cluster.

What to Do Next?

© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.