Cache Memory
This page discusses different cache memory configuration options available in NCache (such as Buffer size, LOH (Large Object Heap) Size, Windows Events Logging, Response Data Size, and more) along with when they should be implmented and why.
Configure Cache Memory Settings
Following are some cache memory configuration settings including the Buffer Size, LOH (Large Object Heap) Size, and other configurations.
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 80Kb 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 512Kb.
<add key="NCacheServer.LOHPoolBufferSize" value="512"/>
Configure Windows Events Logging
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"/>
Configure Response Data Size
NCache introduces Response Data Size 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"/>
Configure Enumeration
The purpose of introducing Enumeration is to keep the cache free from locking while enumerating the cache data. 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:
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"/>
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"/>
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"/>
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"/>
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
GC collection on a specified interval. This value is in minutes.
GC collection can be stopped by providing a value of 0.
<add key="NCacheServer.ServiceGCCollectionInterval" value="180"/>
<add key="NCacheServer.StateTransferDataSizePerThread" value="5"/>
For Mirror and Partition-Replica Cache Topologies, items are asynchronously replicated to the backup nodes in bulk. This is the number of items in one bulk sent to the backup node in a single async call.
<add key="NCacheServer.BulkItemsToReplicate" value="50"/>
See Also
Configure Caches
Cache Settings
Server Connectivity
Windows Events