In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
one。 Slow query log
The slow query log helps developers and operators to locate slow operations in the system. The slow query log is that the system calculates the execution time of each command before and after the command execution. When the preset threshold is exceeded, the relevant information of the command (slow query ID, occurrence time stamp, time consuming, command details) is recorded. The fame and wealth of the Redis client is divided into the following four parts:
It should be noted that the slow query log only counts the time it takes to execute the command in step 3), so slow query does not mean that the client does not have a timeout problem.
two。 Configuration parameter for slow query 2.1.Preset threshold slowlog-log-slower-than for slow query
The slowlog-log-slower-than parameter is the default threshold in microseconds, and the default value is 1000. If the execution time of a command exceeds 10000 subtleties, it will be recorded in the slow query log.
If the value of slowlog-log-slower-than is 0, all commands are logged.
If the value of slowlog-log-slower-than is less than 0, no command will log.
2.2 length of slow query log slowlog-max-len
Slowlog-max-len simply states the maximum number of slow log entries to be stored. Redis uses a list to store slow query logs, and showlog-max-len is the maximum length of the list. When the slow query log has reached the maximum length of the list, and there is a slow query log to enter the list, the log that was first inserted into the list will be removed from the list and the new log will be inserted at the end of the list.
The composition of three slow query logs
The slow query log consists of the following four attributes: identification ID, occurrence timestamp, command time consumption, command execution and parameters
Access and management of four slow log 4.1 get slow log slowlog get [n]
Command: slowlog get [N]
Optional: n, optional, represents the number of log entries obtained
For example: showlog get 5
Return:
1) 1) (integer) 1
2) (integer) 1499338521
3) (integer) 10101
4) 1) "SETEX"
2) "com.yonyou.iuap.portal.integration.ticket.entity.Ticket/AhZwvMNspZnYEy3Zs5BhdA"
3) "3600"
4) "{\" id\ ":\" AhZwvMNspZnYEy3Zs5BhdA\ ",\" usercode\ ":\" b540903b584144d38a365a1fc593ee68\ ",\" expire\ ": 1499342121122,\" extendAttributes\ ": {}"
2) 1) (integer) 0
2) (integer) 1499251333
3) (integer) 42683
4) 1) "HGETALL"
2) "IUAP_SESSION_USER:b540903b584144d38a365a1fc593ee68"
4.2 get the current length slowlog len of the slow query log list
Command: slowlog len
Return: the current length of the slow log list
For example: slowlog len
Return: 2
4.3 slow query log reset slowlog reset
The slow log reset actually cleans up the list.
Command: slowlog reset
For example: slowlog reset
Slowlog len
Return: 0
Five best practices for slow query logs
(1) suggestions for setting up slowlog-max-len
It is recommended for online environment to adjust the list of slow query logs. When recording slow query logs, Redis will truncate long commands and will not take up a lot of memory. Increasing the slow query list can slow down the possibility of slow query being removed from the list. For example, online can be set to more than 1000.
(2) suggestions for setting up slowlog-log-lower-than
This value needs to be adjusted according to the concurrency of redis. Because redis uses a single thread to respond to fame and fortune, for high traffic scenarios, if the execution time of the command is more than 1 millisecond, then redis can support OPS (operations per second) less than 1000 at most. Therefore, it is recommended to set REDIS to 1 millisecond for high OPS scenarios.
(3) slow query only records the command execution time, and does not include the command queue time and network transmission time. So the client
The execution time of the command is longer than the actual execution time of the redis server. Because the command execution is queued to the extreme, slow query will cause command cascade blocking, so when the client has a request timeout, it is necessary to check whether there is a corresponding slow query at this point in time, so as to analyze whether the command cascade blocking is caused by slow query.
(4) slow log is a first-in-first-out queue. When there are many slow queries, some slow query commands may be lost. You can execute slow get commands regularly to persist the slow query logs to other storage. Then make a visual interface query.
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.