Redis uses slowlog to record the query execution time logging system. Note that this query execution time does not include IO operations such as client response (talking) and sending replies, but only the time spent executing a query command.
slowlog is stored in memory and has very fast read and write speeds, so we can use it with confidence without worrying about damaging the speed of Redis by turning on slowlog.
slowlog has two important configurations. We first use the CONFIG GET slowlog-* command to view the existing configuration.
slowlog-log-slower-than indicates the threshold for slow queries, in microseconds. If the execution time of a query command exceeds the set limit threshold, the command will be recorded in the slow query log. Log all commands when slowlog-log-slower-than=0. When the value of slowlog-log-slower-than is less than or equal to 0, no commands will be logged. The default value for slowlog-log-slower-than is 10000 (10 milliseconds, 1 second = 1,000 milliseconds = 1,000,000 microseconds).
slowlog-max-len represents the maximum number of slow query logs. This is a first-in-first-out queue storage structure. When the number of slow query log entries reaches the upper limit, the oldest recorded log entry will be destroyed. The default value of slowlog-max-len is 128, which is stored in memory, so restarting redis will clear the slow query log.
The commands to configure slowlog-log-slower-than and slowlog-max-len are very simple, as follows:
The above is the detailed content of What is the use of slowlog in Redis?. For more information, please follow other related articles on the PHP Chinese website!