Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to reject bigkey in Redis development specification

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

How to do the rejection bigkey in the Redis development specification, for this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more small partners who want to solve this problem find a simpler and easier way.

Code Review alone is not enough. Code Review is mainly to solve the specification problem, of course, can also identify some bugs.

Code Review is suitable for technology-driven teams, public service teams, test-deficient teams, rookies intensive teams, and any team with subjective intentions. Code Review activities are mainly carried out around the following four tasks.

When it comes to code specifications, we have to mention Alibaba Cloud's Redis development specification. This standard is very well written and I want to summarize everything I said. If you need this set of specifications, you can privately write to me and I will send them to you.

One of them reads:

We all understand the meaning, the key is that this bigkey is not easy to master, using the key may become larger, not standard.

So is there a big Key detection mechanism? Of course there are answers. Alibaba Cloud provides a big Key search tool: https://yq.aliyun.com/articles/117042. The principle is actually similar to what we're going to do next.

Because sometimes, our BUG is unintentional direct generation, bigkey may also be your lack of knowledge, lack of consideration and other reasons caused. Therefore, for some problems in production, we also need to take the initiative to observe the health of each service. Let's take a look at how to use unreasonable large keys in Redis in advance.

The command redis-cli -h{ip} -p{port} bigkeys does exactly that. This command samples the keys in redis, looking for larger keys. The scan mode is used, so don't worry about blocking redis for a long time and can't handle other requests. The results of the execution can be used to analyze the memory usage status of redis, the average size of each type of key.

For example, when I execute: redis-cli -h 127.0.0.1-p 7001 -bigkeys, the following appears:

String is a string, Hash is a hash, List is a list, Set is a set, zset(sorted set).

String type: It is generally believed that anything over 10k is a bigkey, but this value is related to the specific OPS.

Non-string types: too many elements in hash, list, collection types.

Bigkey usually causes memory imbalance, timeout blocking, if the key is large, redis is a single thread, operation bigkey is more time-consuming, then the possibility of blocking redis increases. Each time the network traffic to obtain a bigKey is large, assuming that a bigKey is 1MB and the number of accesses per second is 1000, then 1000MB of traffic per second is generated. For an ordinary Gigabit NIC, a server with 128M/S in bytes may not be able to withstand it. In addition, servers are generally deployed in a single-machine multi-instance manner, so other instances may also be affected.

When you think you can use Redis, you can find a high-paying job, but in fact, it is important to optimize!

About how to do the Redis development specification in the rejection of bigkey questions to share the answer here, I hope the above content can be of some help to everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report