In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "what are the Redis specifications?", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what are the Redis specifications?"
Redis has powerful functions and rich data types, and no matter how fast the system is, it can't stand crazy abuse. By disabling some of the high-risk features and putting on the shackles of development, the business is better able to think about problems in a concise, general-purpose way, rather than tied to an implementation.
Redis has different persistence and eviction strategies depending on its purpose, so before using and applying for a Redis cluster, please specify whether it is used for caching or storage. Redis cluster has two modes: master-slave mode and cluster mode, each of which has its own advantages and disadvantages. The following specifications do not distinguish between cluster modes, which are explained in terms of usage scenarios and operational restrictions.
Distinguish between hot and cold data using the specification
Although redis supports persistence, storing all data in redis is very expensive. It is recommended to load hot data (such as QPS more than 5k) into redis. Low frequency data can be stored in Mysql and ElasticSearch.
Business data separation
Don't put unrelated data services into one Redis. On the one hand, it avoids the interaction of business, on the other hand, it avoids the expansion of single instance, and can reduce the influence area in the event of failure and recover quickly.
Message size limit
Because Redis is a single-threaded service, messages block and slow down other operations. It is a good habit to keep the content of the message below 1KB. It is forbidden to record more than 50KB. Too large messages can also cause high usage of network bandwidth and IO problems when persisted to disk.
Number of connections limit
The frequent creation and destruction of connections will waste a lot of system resources, and the extreme case will cause the host to crash. Ensure that the correct Redis client connection pool configuration is used.
Cache Key setting expiration time
For Key, which is used as a cache, the expiration time must be set. The failure time is not as long as possible. Please set it according to the nature of the business. Note that the units of failure time are some seconds and some milliseconds. Many students are easy to make mistakes if they don't pay attention.
Cache cannot have intermediate state
The cache should only be used for caching. After removing the cache, the business logic should not be changed and must not be cut into the business. First, the high availability of the cache will affect the business; second, the deep coupling will have an unpredictable effect; third, it will have a skin effect on the maintenance line.
Client hash is preferred for expansion mode.
Forget the mini app.
If a single redis cluster does not serve your data, don't rush to expand your redis cluster (including redis S and Cluster). The larger the cluster, the worse the performance in terms of state synchronization and persistence. The client-side hash is preferred for cluster split. For example, according to the user id, it is divided into 10 clusters, and the user with the tail number 0 falls in the first cluster.
Operation restrictions strictly prohibit the use of Keys
The Keys command is extremely inefficient, is an O (N) operation, blocks other normal commands, and on cluster can be a catastrophic operation. Use is strictly prohibited. DBA should rename this command and disable it from the root.
The use of Flush is strictly prohibited
The flush command clears all data, which is a high-risk operation. Strictly forbidden, DBA should rename this command, disabled from the root, only DBA can be operated.
It is strictly forbidden to use as a message queue.
If there are no very special requirements, it is forbidden to use Redis as a message queue. When Redis is used as a message queue, there will be a variety of problems in terms of capacity, network, efficiency and function. If you need message queuing, you can use high throughput Kafka or highly reliable RocketMQ.
Batch operations without setting scope are strictly prohibited
Redis is so fast, and slow queries belong to these batch operation functions except for network latency. Most online problems are caused by these functions.
1. [zset] it is forbidden to operate zset without scope.
ZRANGE, ZRANGEBYSCORE and other functions that operate on ZSET are forbidden to use operations such as ZRANGE myzset 0-1 that do not set a range. Please specify a range, such as ZRANGE myzset 0100. If the length is uncertain, you can use ZCARD to determine the length.
2. [hash] it is forbidden to use HGETALL for Key with large amount of data.
HGETALL will fetch all the data of the relevant HASH. If the number of data bars is too large, it will also cause blocking. Please ensure that the business is under control. If you are uncertain about the length, you can use HLEN to determine the length first.
3. [key] mget operation of Redis Cluster cluster
The MGET operation of Redis Cluster will aggregate the data from each shard. Compared with the traditional Mmax S architecture, the performance will be much lower. Please stress test and evaluate in advance.
4. [other] it is forbidden to use sunion, sinter, sdiff and other aggregation operations to disable the select function.
The select function is used to switch database, which is a problem-prone place for users, and cluster mode does not support multiple database, and there is no benefit, so disable it.
Disable transactions
Redis itself is already fast, and if it is not necessary, it is recommended to catch exceptions and roll back instead of using transaction functions, which are rarely done.
Disable lua script extension
Although the lua script can do a lot of things that look like cool, it is like a stored procedure for SQL, which introduces performance and some problems that are difficult to maintain.
Prohibition of long-term monitor
The monitor function can quickly see the data flow currently being executed by redis, but beware that blocking the monitor command for a long time during peak periods can seriously affect the performance of redis. The use of this command is not prohibited, but special attention must be paid to the use.
Key specification
The Key of Redis must be standardized so that it can be easily located when there is a problem. Redis is a scheme-free KV database, so we rely on conventions to establish its scheme semantics. The benefits are:
Ability to clean up data according to a certain type of key
Ability to update data according to a certain type of key
Be able to know the ownership and application scenarios of a certain type of key
Prepare for unification and platform and reduce technological change
Generally, a key needs to have the following dimensions: business, key usage, variables, etc. Each dimension is separated by: the following are several instances of key:
Gender of 10002232 of user:sex users
Ranking of the number of user statements in msg:achi 201712
The above is about the content of this article on "what are the Redis specifications?", I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.