Redis is powerful and has a rich data set. By disabling some of the high-risk features and hanging on the development of shackles, developers can think about problems in a concise, versatile way, rather than binding on some implementation.
Redis has different persistence and eviction policies depending on the application. Therefore, before using and applying for a Redis cluster, please explicitly use it for caching or storage. Redis clusters have master-slave and cluster modes, each with advantages and disadvantages. The following specifications do not distinguish between cluster modes. We explain them in terms of usage scenarios and operational limitations.
Running Redis on Windows 10
If you want to run Redis smoothly on the Windows 10 platform, you need a legitimate product key to activate Windows 10.
Hot and cold data distinction
Although Redis supports persistence, storing all data in Redis is very expensive. It is recommended to load data from hot data (eg QPS over 5k) into Redis. Low frequency data can be stored in Mysql, ElasticSearch.
Business data separation
Don’t put irrelevant data traffic in a Redis. On the one hand, avoid business interactions. On the other hand, avoiding single instance expansion, you can reduce the impact surface in case of failure and recover quickly.
Message size limit
Because Redis is a single-threaded service, messages overcoming blocking and slowing down other operations on the system. Keeping the message content below 1KB is a good habit. Single records over 50KB are strictly prohibited. If the message size is too large, it will cause high network bandwidth and IO problems when it is persisted to disk.
Frequent creation and destruction of connections can waste a lot of system resources, and the limit will cause the host to crash. Make sure you are using the correct Redis client connection pool configuration.
Set the cache key expiration time
The Key used as a cache must have an expiration time set. The expiration time is not as long as possible, so please set it according to the nature of the business. Note that the unit of failure time is seconds, and some are milliseconds. Many developers don’t pay attention to mistakes.
Cache cannot have intermediate state
The cache should only be used for caching. After the removal, the business logic should not be changed, and it must not be cut into the business.
- The high availability of the cache will affect the business
- The deep coupling will have unpredictable effects
- It will have a negative effect on maintenance
Preferred client hash extension
Do not use Keys
The Keys command is extremely inefficient and belongs to O(N) operation and should be strictly prohibited. This command will block other normal commands, which can be catastrophic on a cluster. The DBA should rename this command and disable it from the root.
Flush is strictly prohibited
The flush command clears all data and is a high-risk operation, and only the DBA can operate it. It is strictly forbidden for normal developers to use it. The DBA should rename this command and disable it from the root.
Do not use Redis as a message queue
Redis is strictly prohibited as a message queue if there are no very special requirements. If you use Redis as a message queue, you will have multiple problems with capacity, network, efficiency, and functionality. For message queues, use high-through Kafka or highly reliable RocketMQ.
Do not use batch operations without setting range
Do not operate on zset without scope
Take the functions of ZSET, ZRANGE, ZRANGEBYSCORE, etc. as an example. It is strictly forbidden to use ZRANGE myzset 0 -1 and so on. Please specify a range, such as ZRANGE myzset 0 100. If you are unsure of the length, you can use ZCARD to determine the length.
It is strictly forbidden to use HGETALL for large data volume Key
HGETALL will take all the data of the relevant HASH. If the number of data is too large, it will also cause blocking. Please ensure that the business is controllable. If you are unsure of the length, you can use HLEN to determine the length first.
Redis Cluster’s mget operation
Redis Cluster’s MGET operation will aggregate data into each fragment, and performance will drop a lot compared to the traditional M/S architecture. Before using this command, please press and evaluate in advance.
It is strictly forbidden to use some polymerization operations such as sunion, sinter, sdiff.
Disable the select function
Disable lua script extensions
Prohibit long time monitor
Redis Cluster goals Redis Cluster is a distributed implementation of Redis with the following goals, in order of importance in the design: High performance and linear scalability up to 1000 nodes. There are no proxies, asynchronous replication is used, and no merge operations are performed on values.