This topic describes how to view slow logs that are collected during a specified period of time in the ApsaraDB for Redis console. You can view slow logs to resolve 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 your instance uses a version of ApsaraDB for Redis that is earlier than Redis 4.0, you can upgrade the instance version after you assess 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 (Tair) instances are used.

Background information

Slow logs record requests whose execution time exceeds a specified threshold. Slow logs are classified into the data node slow log and proxy slow log.
Note Slow logs of only data nodes are collected for standard instances.
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 includes only the command execution time on the data node. The time that is required for the data node to communicate with a proxy or client, and the latency of the command in the single-threading queue are not included.
  • In most cases, the number of slow logs of data nodes is small due to the high-performance capabilities of ApsaraDB for Redis.
  • slowlog-log-slower-than: specifies the command execution time threshold. If a command runs for a period of time that exceeds this threshold, the command is recorded in a slow log. Default value: 20000 μs (20 ms).
    Note In most cases, the latency is higher than the specified value of this parameter because the value does not include the time required 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 Parameters overview.

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 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. The number of proxy slow logs is not limited.
  • In most cases, the latency value recorded in a proxy slow log is similar to the actual latency of the application. However, we recommend that you check the accuracy of this value 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 close to the client timeout value, which is from 200 to 500 ms.

For more information, see Parameters overview.

Procedure

  1. Log on to the ApsaraDB for Redis console.
  2. In the top navigation bar of the page, select the region where the instance is deployed.
  3. On the Instances page, click the ID of the instance.
  4. In the left-side navigation pane, choose Logs > Slow Logs.
  5. Specify filter conditions to filter results based on your business requirements.
    Filter log data
    No. Description
    1 Select the node type and node ID.
    Note For standard instances, only slow logs of data nodes are collected. If you use standard instances, skip this step.
    2
    3 Specify a time range. By default, slow logs that are collected during the previous day are displayed.
    4 Enter a keyword to filter slow logs, such as bgsave.
    Note By default, the cluster instance of Community Edition is connected by using the endpoint of the proxy server. When you connect to a cluster instance of Community Edition by using the default endpoint, the Host Address displayed on the Data nodes tab are the IP addresses of proxy nodes instead of the client IP addresses. To display the client IP addresses on the Data nodes tab instead of proxy nodes, you can use a private endpoint to connect to the instance. 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). This edition provides client IP addresses in data node logs.

References

Use slow logs to troubleshoot timeout issues