All Products
Search
Document Center

ApsaraDB for Redis:Query slow logs

Last Updated:Jul 17, 2023

You can view the slow logs of an instance in the Tair console so that you can troubleshoot performance issues and optimize requests.

Background information

Slow logs record requests that take longer than a specified threshold to execute in ApsaraDB for Redis. Slow logs are classified into slow logs from data nodes and slow logs from proxy nodes.

Slow log typeDescriptionParameter
Slow logs from data nodes
  • The command execution duration 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.
  • Slow logs from data nodes are retained for 72 hours. The number of slow logs that can be stored is unlimited.
  • In most cases, a small number of slow logs are generated on data nodes due to the high performance of ApsaraDB for Redis.
  • slowlog-log-slower-than: the threshold of the command execution duration 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: microseconds. This value is equivalent to 20 milliseconds.
    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, proxy nodes, and data nodes.
  • slowlog-max-len: the maximum number of slow log entries that can be stored. Default value: 1024.
Slow logs from proxy nodes
  • The command execution duration 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 duration on the data node, the data transmission duration 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 that can 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. Therefore, we recommend that you check this slow log type when you troubleshoot timeout issues.
rt_threshold_ms: the threshold of the command execution duration for slow logs from proxy nodes. Default value: 500. Unit: milliseconds. We recommend that you set the threshold to a value close to the client timeout period, which is from 200 milliseconds to 500 milliseconds.
For more information, see Modify the values of parameters for 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 that you want to manage resides. 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 logs
    No.Description
    The node type and node ID.
    Note If the instance uses the standard architecture, only the slow logs from Data Node are displayed. In this case, skip this step.
    The time range to query. By default, slow logs collected during the last hour are displayed.
    The keyword that is specified to filter slow logs. Example: bgsave.
    Note By default, the Host Address parameter for master-replica cluster 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 the values of parameters for an instance.

Execution durations of specific slow SQL statements

Note Specific slow SQL statements are not related to the actual execution rate of your requests but related to the engine logic of an instance. As such, you can ignore the following slow SQL statements:
  • latency:eventloop

    Tair uses the event-driven mode during runtime. An event loop consists of reading, parsing, and running commands and returning outputs. A latency:eventloop statement indicates the amount of time consumed by an event loop.

  • latency:pipeline

    Tair allows the client to work in pipeline mode. In this mode, the client sends commands and receives outputs in batches. If your instance uses the cluster architecture, proxy nodes use the pipelining mode to send requests in batches to the backend of Tair. A latency:pipeline statement indicates the amount of time consumed by a batch of client requests in pipelining mode.

  • latency:fork

    The execution duration of a latency:fork statement indicates the amount of time required to fork a child process. The larger the amount of data, the longer the time required.

Related API operations

API

Description

DescribeSlowLogRecords

Queries the slow logs of an ApsaraDB for Redis instance that are generated during a specified period of time.

References

Use slow logs to troubleshoot timeout issues