Cache Memory
This page discusses different cache memory configuration options available in NCache, along with when they should be implemented and why.
Buffer size
The Buffer Size of the client socket can be specified in the service config. SendBufferSize
will specify the send buffer size of the connected client socket, in bytes.
<add key="NCacheServer.SendBufferSize" value="131072" />
ReceiveBufferSize
will specify the receive buffer size of the connected client socket, in bytes.
<add key="NCacheServer.ReceiveBufferSize" value="131072" />
LOH (Large Object Heap) Size
A buffer with a size greater than 80 Kb is created on the Large Object Heap(LOH). Garbage Collector doesn't compact the large heap for better performance. Therefore, NCache uses a pool for large buffers. NCache reserves two buffers per client. These buffers are allocated through the LOH buffer pool. The LOHPoolSize
refers to the initial size of the pool, i.e., how many buffers are allocated initially. LOH pool can increase its size by LOHPoolSize on demand.
<add key="NCacheServer.LOHPoolSize" value="40" />
LOHPoolBufferSize
is the size of an individual buffer allocated by the LOH Pool. The default buffer size is 512 Kb.
<add key="NCacheServer.LOHPoolBufferSize" value="512" />
Cache Size Threshhold
CacheSizeThreshold
is the size of the cache in percentage of the total cache size. When this threshold is reached, a warning message is logged into the system event log. No warning message is logged if the following line is commented.
<add key="NCacheServer.CacheSizeThreshold" value="80" />
The CacheSizeReportInterval
is the interval in minutes, during which the CacheSizeThreshold
warning is issued once. If cache size falls below the CacheSizeThreshold
due to eviction and again crosses the CacheSizeThreshold
limit during this interval, no warning is generated. The minimum value is 5 minutes.
<add key="NCacheServer.CacheSizeReportInterval" value="15" />
Response Data Size
The purpose of Response Data Size is to limit the large result sets returned in response to bulk Search, Tags, and Group operations. The .NET framework does not support the serialization of large result sets which exceed the size of 1.9 GB. To solve this problem, NCache splits the large result sets into smaller chunks of data.
The NCacheServer.ResponseDataSize
can be used to specify the size of a response. It will help in limiting a response size by dividing the bigger response into multiple responses each containing the data approximately equal to the specified limit. These multiple responses will be merged by the NCache client as a single response. Here, it takes value in MBs. The default size is 1024 MB.
<add key="NCacheServer.ResponseDataSize" value="1024" />
Enumeration
Enumeration in NCache is designed to allow cache data to be browsed without locking the cache itself. This process eventually increases the cache performance and its availability for clients. NCache follows the technique of taking snapshots of cache data and sending it to the client for enumeration which keeps the cache free from being locked during the process of enumeration. Four attributes are defined for enumeration, which are:
Snapshot Pooling by Cache Size
The NCacheServer.SnapshotPoolingCacheSize
can be used to specify the size of the cache (in terms of the number of items) for enabling enumeration on the cache. It will help in deciding whether to create a pool of snapshots for enumeration or not. A complete snapshot of the cache is returned to the enumerator until the threshold reaches its limit. Once the threshold value is crossed, the cache will create a pool of snapshots that will hold those snapshots based on time slicing. These snapshots will be provided to the enumerator on demand from the client by the cache server. The default size is 100,000 items in cache.
<add key="NCacheServer.EnableSnapshotPoolingCacheSize" value="100000" />
Snapshot Pool Capacity
NCacheServer.SnapshotPoolSize
can be used to specify the number of snapshots allowed in the pool for enumeration. Once the pool reaches its maximum limit, it won’t allow more snapshots to be added to the pool. It will wait till any existing snapshot in the pool has been removed. The default size is 10 snapshots in the cache snapshot pool.
<add key="NCacheServer.SnapshotPoolSize" value="10" />
Snapshot Creation Interval
The NCacheServer.SnapshotCreationThreshold
can be used to specify after how many seconds a new snapshot will be added to the pool for enumeration purposes. The same cache snapshot from the pool is provided to all enumerators on the cache until the threshold time has elapsed. Any enumerator that requests a snapshot after that will get a new snapshot from the pool. The default size is 30 seconds.
<add key="NCacheServer.SnapshotCreationThreshold" value="30" />
Enumerator Chunk Size
The NCacheServer.EnumeratorChunkSize
can be used to specify the chunk size for enumeration. Chunk size is the number of cache items returned to the enumerator from the cache server. Once the enumerator is done enumerating through a chunk of data, it will get the next chunk from the cache server for enumeration. The default size is 1000 items returned in each chunk.
<add key="NCacheServer.EnumeratorChunkSize" value="1000" />
Garbage Collection Frequency
The value of seconds after which service should check if it needs to do a forced garbage collection. This property dictates how frequently you want to check if a forced garbage collection is required or not. The default value is 20 seconds. The minimum possible value is 5 seconds. NCacheServer.ServiceGCCollectionInterval
can be used for limiting the garbage collection on a specified interval. This value is in minutes. Garbage collection can be stopped by providing a value of 0.
<add key="NCacheServer.ServiceGCCollectionInterval" value="180" />
<add key="NCacheServer.StateTransferDataSizePerThread" value="5" />
See Also
Configure Caches
Cache Settings
Server Connectivity
Windows Events