Data Compression
NCache provides data compression to limit the data traffic between the cluster and client nodes. Data compression stores data in a compressed form which helps utilize limited available memory more efficiently. By default, data compression is disabled. This can be configured using the NCache Management Center.
To see how to enable/disable data compression, refer to the Configuring Compression section.
Why Use Data Compression
Data compression benefits the user in multiple ways. When data is compressed, it takes less space which reduces memory consumption. Compression provides faster performance of the operations since the operations performed on the cache are read/write intensive. The overall network cost is reduced as it takes fewer network trips to transfer data in a network, which eventually reduces time consumption, as well.
Configure Data Compression
Changes made to the NCache compression settings will affect the following configurations in the config.ncconf file, accordingly.
<compression enabled="true" threshold="500kb"/>
The example above mentioned specifies whether the items with a size greater than the threshold provided should be compressed/decompressed on the client side or not.
enabled
: To enable compression, this attribute is set as "True". If this attribute has not been set to "True", then compression is disabled. By default, compression is disabled for all caches so enabled
is "False" by default.
threshold
: Specifies the threshold
value. Only those items that are greater than this value will be compressed/decompressed on the client side (or sometimes on the server side).
What does Data Compression do?
NCache applies GZip Compression for all items greater than the specified threshold value, once data compression is enabled via the NCache Management Center. This provides more memory storage and minimizes network traffic.
On objects of a size less than the specified threshold value, NCache does not apply compression. These items travel through the network and are stored in the cache in their original sizes.
Where does Data Compression Occur?
In most cases, compression/decompression occurs on the client side. But, sometimes, the NCache server does the compression/decompression of the data itself.
Client-side compression/decompression
Client-side compression/decompression occurs if NCache compression is enabled, and if any of the below mentioned cases occurs:
For the items being sent to a remote server by the client with a size greater than the specified threshold, those items need to be compressed before they are sent to the cache servers. Cache servers just store the data without applying any data compression.
If compressed data is requested by the client, then the cache server does not apply any decompression and sends the data in its compressed form over the internet. The client receives the compressed form and decompresses the data itself.
Server-side compression/decompression
Server-side compression/decompression occurs if NCache compression is enabled, and if any of the below mentioned cases occurs:
- For the items that are being loaded through the Cache Startup Loader or Read-Thru Provider, and are of size greater than the specified threshold, these items are compressed by the NCache server. The NCache server compresses this data after receiving it from the data source and before storing it in the cache.
NCache decompresses the compressed data that has to be written to a data source via a configured write-thru or write-behind provider before sending it to the data source.
Data Compression on Client Cache
Client cache compresses the data on its own. If both the server and the client cache have compression enabled, then the server compresses the data according to the server threshold and client cache will compress the data according to its own threshold value. Even if compression is disabled on either of them, data is compressed only for the cache on which it is enabled.
Note
Compression is independent of Cache topologies.
See Also
Security and Encryption
Serialization Format
Configuring Security
Configure Encryption for a Cache