当前位置:网站首页>[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 .
边栏推荐
- Transferring images using flask
- DEX net 2.0 for crawl detection
- [function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram
- Source insight operation manual installation trial
- ninja: build stopped: subcommand failed.
- Installing altaro VM backup
- "C and pointer" - Chapter 13 function pointer 1: callback function 2 (combined with template to simplify code)
- Pytorch through load_ state_ Dict load weight
- 牛客网 JS 分隔符
- Personal outlook | looking forward to the future from Xiaobai's self analysis and future planning
猜你喜欢
[advanced pointer (2)] | [function pointer, function pointer array, callback function] key analysis + code explanation
Final review (Day5)
How do I migrate my altaro VM backup configuration to another machine?
Capacity expansion mechanism of map
Understand one-way hash function
[function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram
Apache+php+mysql environment construction is super detailed!!!
Apache+PHP+MySQL环境搭建超详细!!!
Export the altaro event log to a text file
@Import annotation: four ways to import configuration classes & source code analysis
随机推荐
Deploy crawl detection network using tensorrt (I)
6.23 warehouse operation on Thursday
今天很多 CTO 都是被幹掉的,因為他沒有成就業務
Altaro o365 total backup subscription plan
Configure and use Anaconda environment in pycharm
DEX net 2.0 for crawl detection
大二困局(复盘)
Gan network thought
[branch and cycle] | | super long detailed explanation + code analysis + a trick game
[advanced pointer (2)] | [function pointer, function pointer array, callback function] key analysis + code explanation
[written examination question analysis] | | get [sizeof and strlen] [pointer and array] graphic explanation + code analysis
PHP notes are super detailed!!!
Pessimistic lock and optimistic lock of multithreading
牛客网 JS 分隔符
Redhat7系统root用户密码破解
穀歌 | 蛋白序列的深度嵌入和比對
NG Textarea-auto-resize
2022.7.2day594
Using the ethtool command by example
[together Shangshui Shuo series] day 7 content +day8