当前位置:网站首页>[teacher Zhao Yuqiang] redis's slow query log
[teacher Zhao Yuqiang] redis's slow query log
2022-07-03 05:45:00 【Teacher zhaoyuqiang】
Redis Slow query log helps developers and operation and maintenance personnel locate the slow operation of the system . Slow query log is that the system calculates the execution time of each command before and after the execution of the command , When the default threshold is exceeded , This command will be the relevant information ( The slow query ID, Occurrence timestamp , Time consuming , Command details ) recorded .
Redis A client command is divided into four parts as follows :
It should be noted that , Slow query log is just a statistical step 3) Time of execution of order , So slow query does not mean that the client has no timeout problem . It should be noted that , Slow query log is just a statistical step 3) Time of execution of order , So slow query does not mean that the client has no timeout problem .
One 、 Configuration parameters for slow queries :
- Default threshold for slow query slowlog-log-slower-than
slowlog-log-slower-than The parameter is the default threshold , The unit is microseconds , The default value is 10000, If the execution time of a command exceeds 10000 subtle , Then it will be recorded in the slow query log .
If slowlog-log-slower-than The value of is 0, All orders will be recorded .
If slowlog-log-slower-than The value is less than 0, Then no command will log .
- Slow query log length slowlog-max-len
slowlog-max-len It just shows how many slow query logs can be stored at most .Redis Use a list to store slow query logs ,showlog-max-len Is the maximum length of the list . When the slow query log has reached the maximum length of the list , Another slow query log to enter the list , The first log inserted into the list will be removed from the list , The new log is inserted at the end of the list .
Two 、 Composition of slow query log
The slow query log consists of the following four properties :
identification ID, Occurrence timestamp , The command takes time , Execute commands and parameters
3、 ... and 、 Slow query log access and management
Get slow query log slowlog get [n]
command :slowlog get [N]
The selection :N, Optional , Represents the number of log entries obtained
for example :showlog get 5
Four 、 Slow query log best practices
- slowlog-max-len Suggestions for setting up
It is recommended to increase and slow down the list of query logs in the online environment , When logging slow queries Redis Will truncate long commands , It doesn't take up a lot of memory . Increasing the list of slow queries can slow down the possibility that slow queries will be removed from the list . For example, the line can be set to 1000 above .
- slowlog-log-lower-than Suggestions for setting up
Need basis redis The concurrency value is adjusted . because redis Using single thread response fame and fortune , For high traffic scenarios , If the order is executed at 1 Milliseconds or more , that redis Support at most OPS( Number of operations per second ) Less than 1000, So high OPS Of the scene REDIS Recommended setting is 1 millisecond .
- Slow queries only record command execution time , Does not include command queuing time and network transmission time .
Therefore, the execution time of client command is longer than redis The time the server actually executed the command . Because command execution queuing is extreme , Slow queries can cause command cascading blocking , So when the client has a request timeout , You need to check whether there is a corresponding slow query at this time point , So as to analyze whether the command cascade blocking caused by slow query
- The slow query log is a first in, first out queue
When there are more slow queries , Some slow query commands may be lost , It can be carried out on a regular basis slow get Command to persist slow query logs to other stores . Then make a visual interface query .
边栏推荐
- Apache+php+mysql environment construction is super detailed!!!
- Detailed explanation of iptables (1): iptables concept
- [written examination question analysis] | | get [sizeof and strlen] [pointer and array] graphic explanation + code analysis
- The request database reported an error: "could not extract resultset; SQL [n/a]; needed exception is org.hibernate.exception.sqlgram"
- Installing altaro VM backup
- [explain in depth the creation and destruction of function stack frames] | detailed analysis + graphic analysis
- Final review Day8
- Source insight License Activation
- 大二困局(复盘)
- 2022.DAY592
猜你喜欢
Apache+php+mysql environment construction is super detailed!!!
Together, Shangshui Shuo series] day 9
Sophomore dilemma (resumption)
[set theory] relational closure (reflexive closure | symmetric closure | transitive closure)
[advanced pointer (2)] | [function pointer, function pointer array, callback function] key analysis + code explanation
Why should we rewrite hashcode when we rewrite the equals method?
为什么网站打开速度慢?
Map的扩容机制
PHP notes are super detailed!!!
[written examination question analysis] | | get [sizeof and strlen] [pointer and array] graphic explanation + code analysis
随机推荐
Notepad++ wrap by specified character
6.23星期四库作业
Introduction to redis using Lua script
Personal outlook | looking forward to the future from Xiaobai's self analysis and future planning
中职网络子网划分例题解析
mysql启动报错:The server quit without updating PID file几种解决办法
How to install and configure altaro VM backup for VMware vSphere
Together, Shangshui Shuo series] day 9
[trivia of two-dimensional array application] | [simple version] [detailed steps + code]
@Autowired 导致空指针报错 解决方式
【一起上水硕系列】Day 7 内容+Day8
AtCoder Beginner Contest 258(A-D)
Redhat7系统root用户密码破解
6.23 warehouse operation on Thursday
"C and pointer" - Chapter 13 function pointer 1: callback function 2 (combined with template to simplify code)
Shanghai daoning, together with American /n software, will provide you with more powerful Internet enterprise communication and security component services
Detailed explanation of iptables (1): iptables concept
ROS Compilation Principle
[minesweeping of two-dimensional array application] | [simple version] [detailed steps + code]
[branch and cycle] | | super long detailed explanation + code analysis + a trick game