Configure Memory
This page discusses different memory configuration options available in NCache, such as SendBufferSize
, ReceiveBufferSize
, LOHPoolSize
, LOHPoolBufferSize
, CacheSizeThreshold
, and more.
Important
In case you want to update any cache settings, please refer to the Update Cache Config section to follow the set of steps.
Configure Memory Settings
Buffer size
The Buffer Size of the client socket can be specified in the service config.
SendBufferSize
will specify 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 having a size greater than 80Kb is created on the Large Object heap(LOH). Garbage Collector doesn't compact the large heap for its 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. 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 the percentage of 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"/>
CacheSizeReportInterval
is the interval in minutes during which the CacheSizeThreshold
warning is issued once. If cache size falls below 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 operations. The .NET framework does not support the serialization of large result sets which exceed the size of 1.9Gb. To solve this problem, NCache splits the large result sets into smaller chunks of data.
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 1024MB.
<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:
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 the 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"/>
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"/>
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 to limit 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"/>
For Partition-Replica Cache Topology, 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 the single async call.
<add key="NCacheServer.BulkItemsToReplicate" value="50"/>
See Also
Configure Caches
Cache Settings
Server Connectivity
Windows Events