This topic describes how to view slow logs 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 major 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 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.
  • The instance is an instance of ApsaraDB for Redis Community Edition or a performance-enhanced instance of ApsaraDB for Redis Enhanced Edition (Tair).

Background information

Slow logs record requests that take longer to execute than a specified threshold. Slow logs are classified into slow logs from data nodes and slow logs from proxy servers.
Note Only the slow logs from 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 time required to actually run a command on the data node. The time required for the data node to communicate with a proxy or client and the latency of the command in the single-threaded queue are not included.
  • In most cases, the number of slow logs from data nodes is small due to the high-performance capabilities of ApsaraDB for Redis.
  • slowlog-log-slower-than: specifies the threshold of command execution time for slow logs from data nodes. If a command runs for a period of time that exceeds this threshold, the command is recorded in a slow log. Default value: 20000. Unit: μs. 20000 μs is equal to 20 ms.
    Note In most cases, the latency is higher than the specified value of this parameter because this 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 Modify the parameters of an ApsaraDB for Redis instance.

Slow logs from proxy servers
  • The command execution time collected in slow logs from proxy servers starts from the time when a proxy server sends a request to a data node and ends at the time when the proxy server 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.
  • Slow logs from proxy servers are retained for 72 hours. The number of slow logs from proxy servers is unlimited.
  • In most cases, the latency value recorded in a slow log from proxy servers 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 command execution time for slow logs from proxy servers. Default value: 500. Unit: ms. We recommend that you set the threshold to a value close to the client timeout value, which is from 200 ms to 500 ms.

For more information, see Modify the parameters of an ApsaraDB for Redis instance.

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
    Select the node type and node ID.
    Note For standard instances, the slow logs from data nodes are collected only. If you use standard instances, skip this step.
    Specify a time range. By default, slow logs collected during the previous day are displayed.
    Enter a keyword to filter slow logs, such as bgsave.

References

Use slow logs to troubleshoot timeout issues