Recently read the "Redis combat", summed up some of the optimization methods mentioned in How to reduce the Redis memory usage: Use the correct data structure key length smaller occupy memory smaller (add up) value can be processed part of the data structure in the length of the smaller, A small number of cases will be using space-saving algorithm storage, can be combined with sharding to reduce total memory usage sharding: Reduce the amount of storage that can be used on a single machine (although not reduce the total amount of memory) how to reduce the latency of request Redis using the correct data structure A hierarchical structure that reduces the latency of read-only commands the overall idea is to reduce the number of traffic, so in general, try to return the results at the end of the Redis server. Common methods are
(1) Some data structures have the command to handle many information, such as Hmget instead of multiple hget
(2) using pipeline instead of multiple commands to communicate with Redis multiple times
(3) Use LUA script instead of pipeline, watch/multi/exec (pessimistic lock), etc.