This topic describes how to query slow logs in the ApsaraDB for Redis console. This allows you to troubleshoot performance issues and optimize requests.

Prerequisites

  • The database version of the ApsaraDB for Redis instance is Redis 4.0 or later, and the latest minor version is used.
    Note If the instance version does not meet the requirements, you can upgrade the instance version after assessing the compatibility with your business. For more information, see Upgrade the minor version and Upgrade the major version.
  • ApsaraDB for Redis instances of Community Edition instances and performance-enhanced instances of Enhanced Edition instances are used.

Background information

Slow logs are used to record requests whose execution time exceeds a specified threshold. The slow log is classified into the data node slow log and proxy slow log.
Note For standard instances, only slow logs of data nodes are collected.
Slow log type Description Parameter
Slow logs from data nodes
  • The command execution time collected in slow logs that are generated on a data node only includes the command execution time on the data node. The communication time between the data node and a proxy or client, and the latency of the command in the single-threading queue are not included.
  • The number of slow logs of data nodes is small due to the high performance of ApsaraDB for Redis.
  • slowlog-log-slower-than: specifies the threshold of command execution time. If the time consumed to run a command exceeds this threshold, the command is recorded in a slow log. Default value: 10000 μs (10 ms).
    Note Typically, the latency seems to be higher than the specified value of this parameter, because the specified value does not include the time consumed to transmit and process data among clients, proxies, and data nodes.
  • slowlog-max-len: specifies the maximum number of slow logs that can be stored. Default value: 1024.

For more information, see Parameter overview and configuration guide.

Slow logs from the proxy server
  • The command execution time collected in proxy slow logs starts from the time when the proxy server sends a request to a data node and ends at the time when the proxy receives the response from the data node. This time includes the command execution time on the data node, the data transmission time over the network, and the queuing latency of the command.
  • Proxy slow logs are retained for 72 hours. However, the number of proxy slow logs is not limited.
  • The latency recorded in proxy slow logs is similar to the latency that you experience on your application. We recommend that you check this type of logs when you troubleshoot timeout issues.
rt_threshold_ms: specifies the threshold of slow logs from the proxy server. Default value: 500 ms. We recommend that you set the threshold to a value that is similar to the client timeout. The value can be 200 to 500 ms.

For more information, see Parameter overview and configuration guide.

Procedure

  1. Log on to the ApsaraDB for Redis console.
  2. On the top of the page, select the region where the instance is deployed.
  3. On the Instances page, click the Instance ID of the instance.
  4. In the left-side navigation pane, choose Logs > Slow Logs.
  5. Optional:For cluster or read/write splitting instances, specify the node type from which you want to query slow logs.
    Note For standard instances, only slow logs of data nodes are collected. Skip this step.
    Select a node for slow logs
  6. Filter the results based on the specified query time range (within 72 hours) and keywords.
    Filter slow logs
    Note When you connect to a cluster instance of Community Edition by using the default endpoint (the endpoint of the proxy server), the Host Address displayed on the Data nodes tab are the IP addresses of proxy nodes rather than the client IP addresses. You can use a private endpoint to connect to the instance to avoid this restriction. For more information, see Use a private endpoint to connect to an ApsaraDB for Redis instance. To use the endpoint of the proxy server to connect to an instance, you can use ApsaraDB for Redis Enhanced Edition (Tair). Tair provides client IP addresses in data node logs.

References

Use slow logs to troubleshoot timeout issues