# LATENCY

> Find latency spikes by event and see each command's latency distribution.

URL: https://docs.hotkv.com/commands/latency/

```
LATENCY subcommand [argument ...]
```

- Group: Server
- HotKV Cloud: all plans
- On-Premise: no license needed

`LATENCY` is a container command for two kinds of latency data:

- **Latency spikes**, recorded by the latency monitor once you set
  `latency-monitor-threshold` to a number of milliseconds (it is `0`, off,
  by default). Anything that takes at least that long is recorded under an
  event name: `command` for a slow command, `fast-command` for a command
  that is normally fast, and `expire-cycle` for a slow round of removing
  expired keys. Each event keeps its most recent 160 spikes, at most one per
  second (the worst one in that second).
- **Latency distributions** per command, collected all the time while
  `latency-tracking` is `yes` (the default).

`LATENCY HELP` lists the subcommands.

## Subcommands

| Subcommand | What it does |
| --- | --- |
| [LATENCY LATEST](https://docs.hotkv.com/commands/latency-latest/index.md) | The latest and worst spike of each event. |
| [LATENCY HISTORY](https://docs.hotkv.com/commands/latency-history/index.md) | The recorded spikes of one event. |
| [LATENCY GRAPH](https://docs.hotkv.com/commands/latency-graph/index.md) | One event's spikes as a text chart. |
| [LATENCY DOCTOR](https://docs.hotkv.com/commands/latency-doctor/index.md) | A plain-English report on the spikes, with advice. |
| [LATENCY RESET](https://docs.hotkv.com/commands/latency-reset/index.md) | Forget the spikes of some or all events. |
| [LATENCY HISTOGRAM](https://docs.hotkv.com/commands/latency-histogram/index.md) | Per-command latency distribution. |

An unknown subcommand gets `ERR unknown subcommand '<name>'. Try LATENCY HELP.`

## Examples

```
127.0.0.1:6379> CONFIG SET latency-monitor-threshold 50
OK
127.0.0.1:6379> LATENCY LATEST
1) 1) "command"
   2) (integer) 1790000000
   3) (integer) 120
   4) (integer) 340
```

## Compatibility

Same subcommands and reply shapes as Redis 7 and Valkey 8. HotKV records
the `command`, `fast-command` and `expire-cycle` events.

## See also

[SLOWLOG](https://docs.hotkv.com/commands/slowlog/index.md), [INFO](https://docs.hotkv.com/commands/info/index.md) (`latencystats`),
[monitoring](https://docs.hotkv.com/operate/monitoring/index.md), [troubleshooting](https://docs.hotkv.com/operate/troubleshooting/index.md)