When using Smarty in cluster mode on multiple servers and with a heavy load from subscribers, you may face the need to reduce the amount of stored data in Redis and reduce the load on the network when transferring data between Redis and Smarty servers.
Smarty allows you to compress data when stored in cache. This can cut data size and traffic in half.
To enable compression, you must add to the section CACHES OPTIONS parameter COMPRESSORfor example:
CACHES = {
"default":
"Backend": "core.cache.backends.RedisCache,"
“LOCATION”: “redis:// 10.0.0.1:7000/0","
"OPTIONS":
"COMPRESSOR": "django_redis.compressors.zlib.ZlibCompressor,"
"REDIS_CLIENT_CLASS": "rediscluster.client.RedisCluster,"
"REDIS_CLIENT_KWARGS": {"read_from_replicas: True },
"CONNECTION_POOL_CLASS": "core.cache.cluster_connection.ClusterConnectionPool,"
"CONNECTION_POOL_KWARGS": {
"startup_nodes":
{"host": "10.0.0.1", "port": "7000", "server_type: "master"},
{"host": "10.0.0.1", "port": "7000", "server_type: "slave"},
{"host": "10.0.0.1", "port": "7000", "server_type": "slave"}
]
}
}
}
}
Using data compression can slightly increase the load on the CPU.