Redis Slow query logs help development and O&M personnel locate slow operations on the system. The slow query log means that the system calculates the execution time of each command before and after the command is executed. When the time exceeds the preset threshold, the system records the information about the command, including the ID of the slow query, timestamp, time, and detailed command information.
It is important to note that slow query logs only count the time taken to execute the command in Step 3. Therefore, slow query does not mean that the client does not have a timeout problem. It is important to note that slow query logs only count the time taken to execute the command in Step 3. Therefore, slow query does not mean that the client does not have a timeout problem.
Slow query configuration parameters: Slowlog-log-slower than slowlog-log-slower is the default slowlog-slower threshold in microseconds. The default value is 10000. If a command takes more than 10000 milliseconds to execute, it is logged in the slow query log. If slowlog-log-slower than is 0, all commands are logged. If the value of slowlog-log-slower than is less than 0, no commands are logged. If relative electron has more intuitive understanding, it can also refer to its format as follows:
www.walajiao.com
Slowlog-max-len Slowlog-max-len specifies the maximum number of slow query logs to be stored. Redis uses a list to store slow query logs. Showlog-max-len is the maximum length of the list. When the length of a slow query log reaches the upper limit and another slow query log is added to the list, the earliest log is removed from the list and the new log is added to the end of the list.
Slow query logs consist of the following attributes: ID, timestamp, command duration, command execution and parameters
Slowlog get [n] Command: slowlog get [n] Selection: n, optional, indicates the number of page game logs to be obtained. Example: showlog get 5
Slowlog-max-len Setting Recommended Online environment You are advised to increase the slowlog-max-len list. Redis truncates long commands when slowlog-max-len is recorded, which does not occupy a large amount of memory. Increasing the list of slow queries reduces the likelihood that slow queries will be removed from the list. For example, the value can be more than 1000 online.
You are advised to set slowlog-log-lower-than based on the concurrency of Redis. www.walajiao.comredis uses single-thread response. For high-traffic scenarios, redIS can support less than 1000 OPS (operations per second) if the command execution time is more than 1 ms. Therefore, it is recommended to set redIS to 1 ms for high-OPS scenarios.
Slow query only records the command execution time, excluding the command queuing time and network transmission time. Therefore, the execution time of the client command is longer than the actual execution time of the Redis server command. Because command execution queuing is extreme, slow query blocks command cascading. Therefore, when a request times out on the client, you need to check whether the corresponding slow query exists at this point in time to analyze whether the command cascading is blocked due to slow query
Slow query logs are in a first-in, first-out queue. Some slow query commands may be lost. You can run the slow get command periodically to store slow query logs to other stores. Then make a visual interface query.