In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
How to optimize the performance of redis? I believe that many novice rookies' understanding of redis performance optimization is ignorant, the editor gives you some suggestions, through a few suggestions, I hope you can gain more. The following information is about redis performance optimization.
I. recommendations for optimizing the structure of Redis deployment
1. Master does not do AOF or RDB persistence. Slave does AOF persistence. It is recommended to do RDB persistence at the same time.
2. Add Slave to all Master
3. No more than 2 Slave are mounted on Master, and M-S-S is used to mount them. If you want to ensure high availability, that is, master-slave switching, you can use Keepalived mechanism.
Note: the above suggestions are based on the unreasonable deployment structure of Redis, and also refer to the optimization scheme of Redis in Sina Weibo and Taobao architecture.
II. Recommendations for Redis configuration optimization
1.tcp-keepalive 60
Prevent a command from being disconnected because it takes too long to reach the timeout timeout, and can improve the detection of connection errors.
2.stop-writes-on-bgsave-error no
Stop writing data to disk when the bgsave snapshot operation goes wrong, so the subsequent write operation will fail. In order not to affect the subsequent write operation, it is necessary to change the value of this item to no.
3.rdbchecksum no
Checking the correctness of RDB data will sacrifice 10% performance, so it is recommended to turn it off.
4.auto-aof-rotate-max-size 20gb
Auto-aof-rotate-max-total 4auto-aof-rewrite-percentage 0 (turn off rewrite mode)
Change AOF rewrite mode to rotate mode, that is, the function of AOF online real-time Rewrite is switched to offline operation, and one AOF file is cut into multiple parts (similar to log cutting), which improves redis performance and memory utilization at the same time.
5.no-appendfsync-on-rewrite yes
Avoid IO blocking when newly modified data is brushed to disk
Note: the above are optimization suggestions based on unreasonable configuration of Redis.
III. Suggestions for optimizing the configuration of the system kernel
1. AOF mode is enabled to ease IO blocking
Edit / etc/sysctl.conf and add the following configuration:
Vm.dirty_background_ratio = 5vm.dirty_ratio = 10
Then sysctl-p makes the configuration file effective.
two。 RDB mode is enabled to avoid Fork failure
Edit / etc/sysctl.conf, change vm.overcommit_memory=1
Then sysctl-p makes the configuration file effective
Note: the above are the kernel optimization suggestions based on the test results.
Follow-up plan:
The above optimization suggestions are put forward from the perspective of architecture, and from a business point of view, we will analyze whether the type of memory is reasonable, whether the division of hot and cold data is reasonable, and so on.
Note:
For the division of hot and cold data, you can use the following Redis command for statistical analysis:
OBJECT REFCOUNT this command is mainly used for debugging (debugging), it can return the number of times the value corresponding to the specified key is referenced.
OBJECT ENCODING this command returns the representation used by the value corresponding to the specified key.
OBJECT IDLETIME this command returns the time in seconds that the value corresponding to the specified key has been idle since it was stored (requests for no read and write operations). This value returns the level of time in 10 seconds, which may be improved in future implementations.
The above is the introduction of the method of redis performance optimization, and you have to use it yourself to know the specific essentials. If you want to read more related articles, you are welcome to 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.