This feature is only available in NCache Enterprise Edition.
NCache provides a data compression feature to minimize the data traffic between cluster and client nodes and also to make your limited available memory, slightly more useful by storing more data in compressed form. Compression is by default disabled in NCache. You can enable/disable data compression using NCache Manager.
See how to enable/disable compression in Configuring Compression in Administrator's guides.
Why to Use Compression
Compressing the data helps the user in various ways. The data will take less space which reduces memory consumption. Since the operations performed on the cache by the user are read or write intensive, using compression will provide the user with faster performance of the operations. Reducing the network cost of the data transferring in lesser network trips reduces the overall network cost, hence reducing time consumption as well.
Changing NCache compression settings will change the following configurations accordingly in config.ncconf file:
<compression enabled="true" threshold="500kb"/>
This xml tag specifies whether the items greater than the specified threshold should be compressed/decompressed at client side.
enabled: If this attribute is set to "True", it means compression is
enabled, otherwise it is disabled. Its default value is "False", as compression
is disabled by default for all caches.
threshold: Items greater than the value specified in the threshold
attribute will only be compressed/decompressed at client side (or sometimes at
server side) if compression is enabled.
What does Compression do?
Once you enable data compression, and specify the required threshold via NCache Manager, now NCache will apply GZip Compression for all objects of size greater than the specified threshold value, providing more memory storage and minimizing network traffic.
Compression will not be applied on the objects of the size less than the specified threshold value, and they will travel via the network and will be stored in the cache in their original sizes.
Where does Compression Occur?
Compression/decompression mostly occurs at client side, but there are few cases when the NCache server does the compression/decompression of the data.
Client side compression/decompression
This takes place if NCache compression is enabled, and if any of the following cases occurs:
For data with size greater than the threshold being sent by the client to a remote server, data is compressed by the client and sent to the cache server in compressed form. Cache servers just store the data without applying any compression to it.
If a client requests for compressed data in cache from the server, the cache server does not apply any decompression to the data and sends the data in its compressed form over the internet. The client receives the compressed data and decompresses it by itself.
Server side compression/decompression
This takes place if NCache compression is enabled, and any following case occurs:
- For the data being loaded via cache startup loader or read-thru provider and of size greater than the specified threshold, NCache server compresses the data after receiving it from the data source and before storing it in the cache.
For data received by the cache server in compressed form, which has to be written to a data source via configured write-thru or write-behind provider, NCache server decompresses the data first before sending it to the data store.
Compression on Client Cache
Client cache has its own compression. If compression is enabled on both server and client cache, data is compressed according to server threshold on server and according to its own threshold on client cache. Even if compression is not enabled on one of them, data is compressed for the cache on which it is enabled only.
Compression is independent of Cache topologies.