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

An ApsaraDB for Redis instance of one of the following versions is created:

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 nodes.
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 were generated on a data node includes only the amount of time required to actually run a command on the data node. The amount of time required for the data node to communicate with a proxy node or client and the execution 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 actual latency is higher than the specified value of this parameter because this value does not include the amount of time required to transmit and process data among clients, proxies, and data nodes.
  • slowlog-max-len: specifies the maximum number of slow log entries that can be stored. Default value: 1024.

For more information, see Modify parameters of an instance.

Slow logs from proxy nodes
  • The command execution time collected in slow logs from proxy nodes starts from the time when a proxy node sends a request to a data node and ends at the time when the proxy node 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 nodes are retained for 72 hours. The number of slow logs from proxy nodes allowed to be stored is unlimited.
  • In most cases, the latency value recorded in a slow log from proxy nodes is closer to the actual latency of the application. As such, 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 nodes. 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 parameters of an instance.

Procedure

  1. Log on to the ApsaraDB for Redis console and go to the Instances page. In the top navigation bar, select the region in which the instance is deployed. Then, find the instance and click its ID.
  2. In the left-side navigation pane, choose Logs > Slow Logs.
  3. Specify filter conditions to filter results based on your business requirements.
    Filter log data
    No. Description
    The node type and node ID.
    Note For standard instances, only the slow logs from Data Node are collected. If you use standard instances, skip this step.
    The time range to query. By default, slow logs collected during the last hour are displayed.
    A keyword that is specified to filter slow logs. Example: bgsave.
    Note

    By default, the Host Address parameter for master-replica cluster instances and read/write splitting instances displays the IP address of proxy nodes. To obtain the IP address of a specific client, set ptod_enabled to 1 in System Parameters. For more information, see Modify parameters of an instance.

Execution durations of special slow SQL statements

  • latency:eventloop

    ApsaraDB for Redis uses the event-driven mode during runtime. An event loop includes reading command, parsing, and running command, and returning results. The execution duration of a latency:eventloop statement indicates the overall amount of time taken for an event loop.

  • latency:pipeline

    ApsaraDB for Redis allows the client to work in pipeline mode. In this mode, the client sends commands in batches and returns results in batches after all commands are run. The execution duration of a latency:pipeline statement indicates the overall amount of time taken to handle all requests from the client in pipeline mode.

    Note By default, proxy servers of ApsaraDB for Redis cluster instances send requests to the backend Redis server in pipeline mode.

Related API operations

API Description
DescribeSlowLogRecords Queries slow logs of an ApsaraDB for Redis instance in a specified time period.

References

Use slow logs to troubleshoot timeout issues