Skip to content

LATENCY

Note: Not yet supported

The LATENCY command in DiceDB is used to measure and analyze the latency of various operations within the DiceDB server. This command provides insights into the performance and responsiveness of the DiceDB instance, helping administrators to identify and troubleshoot latency issues.

Command Syntax

Terminal window
LATENCY [SUBCOMMAND] [ARGUMENTS]

Parameters

ParameterSubcommandDescriptionReturn TypeRequired
SUBCOMMANDSpecifies the operation to perform. Available subcommands are:StringYes
LATESTReturns the latest latency spikes.ArrayYes
HISTORYReturns the latency history for a specific event.ArrayYes
RESETResets the latency data for specific events or all events.IntegerYes
GRAPHReturns a latency graph for a specific event.StringYes
DOCTORProvides a human-readable report of latency issues.StringYes
ARGUMENTSN/AAdditional arguments required by certain subcommands (if applicable).VariesNo

Return Values

ConditionReturn Value
LATESTArray of latency spikes
HISTORYArray of latency samples (timestamp, latency)
RESETInteger (number of events reset)
GRAPHString (graph representing latency data)
DOCTORString (detailed report with suggestions)
Syntax or specified constraints are invaliderror

Behaviour

When the LATENCY command is executed, it performs the specified subcommand operation. The behavior varies based on the subcommand:

  • LATEST: Fetches and returns the most recent latency spikes recorded by the DiceDB server.
  • HISTORY: Retrieves the historical latency data for a specified event, allowing for analysis of latency trends over time.
  • RESET: Clears the latency data for specified events or all events, effectively resetting the latency monitoring.
  • GRAPH: Generates and returns a visual representation of the latency data for a specified event.
  • DOCTOR: Analyzes the latency data and provides a human-readable report with potential causes and suggestions for mitigation.

Errors

  • Invalid Subcommand:

    • Error Message: ERR unknown subcommand 'subcommand'
    • If an unrecognized subcommand is provided, DiceDB will return an error.
  • Missing Arguments:

    • Error Message: ERR wrong number of arguments for 'latency subcommand' command
    • If required arguments for a subcommand are missing, DiceDB will return an error.
  • Invalid Event Name:

    • Error Message: ERR no such event 'event_name'
    • If an invalid event name is provided for subcommands like HISTORY, RESET, or GRAPH, DiceDB will return an error.

Example Usage

LATEST Subcommand

Fetches the latest latency spikes recorded by the DiceDB server.

Terminal window
127.0.0.1:7379> LATENCY LATEST
1) 1) "command"
2) (integer) 1633024800
3) (integer) 15
2) 1) "fork"
2) (integer) 1633024805
3) (integer) 25

HISTORY Subcommand

Retrieves the historical latency data for the command event.

Terminal window
127.0.0.1:7379> LATENCY HISTORY command
1) 1) (integer) 1633024800
2) (integer) 15
2) 1) (integer) 1633024805
2) (integer) 25

RESET Subcommand

Resets the latency data for the command event.

Terminal window
127.0.0.1:7379> LATENCY RESET command
(integer) 1

GRAPH Subcommand

Generates a visual representation of the latency data for the command event.

Terminal window
127.0.0.1:7379> LATENCY GRAPH command
| 15 | 25 |

DOCTOR Subcommand

Provides a human-readable report of latency issues.

Terminal window
127.0.0.1:7379> LATENCY DOCTOR
Latency Doctor Report:
- Command latency spikes detected. Consider optimizing your commands.
- Fork latency spikes detected. Check your system's I/O performance.