Cache Size
Through this configuration option, you can specify an upper limit on the size of the cache in MBs. The number of items in the cache is limited by the maximum size of the cache and the amount of free system memory (virtual or physical).
Note
This feature is also available in NCache Professional.
If some eviction policy is specified, whenever the total data size in the cache reaches maximum size or when less than 10% of memory is left in the system, items are removed from the cache as per eviction policy. The maximum size of a cache can be specified using the following ways:
Set Cache Size Using the NCache Management Center
Launch the NCache Management Center by browsing to http://localhost:8251 or
<server-ip>:8251
on Windows and Linux.In the left navigation bar, click on Clustered Caches or Local Caches, based on the cache server to start. Against the cache name, click on View Details.
This opens up the detailed configuration page for the cache.
In the Overview tab, click on the button.
Change the Max Cache Size which is in MBs.
- Click on to save the cache configuration.
Set Cache Size Using the Using Command Line Tools
The New Cache tool enables the user to create a new cache on one or more server nodes.
This command creates a local cache of size 1024 MB on the 20.200.20.40 node. Although, you can change it to any size you prefer.
Manually Editing NCache Configuration
Important
Ensure you stop the cache before making any configuration changes.
You can specify the Cache Size through config.ncconf by specifying the <storage>
tag under the <cache-settings>
tag:
<cache-settings cache-name="this" alias="" inproc="False" last-modified="" auto-start="True" data-format="Binary">
...
<storage type="heap" cache-size="1024mb"/>
...
</cache-settings>
- Once the changes are made, start the cache and restart the NCache Service.
Troubleshooting
Out of Memory Problem
This usually happens when the Maximum Size for the cache is not specified correctly. Often, the processing overhead is not considered while specifying the Maximum Size.
Workaround
To resolve memory issues, NCache provides a memory-based cache, where you can specify an upper limit on the size of the cache in MBs.
You should specify a Maximum Size which, if completely consumed, still leaves enough space in the system so that it never presents as low resources.
While specifying the cache size, consider the following factors:
- Average size of Sessions or Objects.
- The number of expected Sessions or Objects.
- The available memory for the NCache process.
Then you can calculate the required memory by keeping the following in mind.
- There is a 15% Overhead per session.
- There is a 15-20% overhead for processing. If the object size is greater than 80KB, this ratio may be a little bit high.
See Also
Cache Isolation Levels
Cache Data Expiration
Error Logging
Management Operations