lats is a experimental benchmarking tool NATS JetStream performance. It allows you to measure throughput and latency for different publishing scenarios.
There are two publishing modes:
- Batch mode is the same as
nats bench js pub async - Pipelined mode publishes a given number of in-flight messages, and when an acknowledgment is is received, a new message is published immediately.
lats [flags]| Flag | Description | Default |
|---|---|---|
-url |
NATS server URL | nats://127.0.0.1:4222 |
-stream |
JetStream stream name | BENCH |
-subject |
Subject to publish messages to | bench.test |
-size |
Message size in bytes | 128 |
-clients |
Number of concurrent publisher threads | 1 |
-batch |
Max batch size per publisher (for batch mode) | 500 |
-inflight |
Max outstanding async publishes per publisher (for pipelined mode). If 0, batch publishing is used. | 0 |
-duration |
Benchmark duration | 10s |
-replicas |
Number of stream replicas | 3 |
-sysurl |
URL for system account connection to find the stream leader (e.g. nats://user:pass@host:port) |
"" |
Run a benchmark with 1 publisher, a batch size of 1000, for 30 seconds:
lats -clients 1 -batch 1000 -duration 30sRun a benchmark in pipelined mode with 16 in-flight messages:
lats -clients 1 -inflight 16 -duration 30sThe tool outputs the benchmark parameters were used and the results in JSON format.
{
"params": {
"publishers": 1,
"inflight": 0,
"batch": 1,
"message_size_bytes": 128,
"duration_sec": 60
},
"results": {
"total_messages": 614323,
"throughput_msg_per_sec": 10238,
"latency_us": {
"min": 58,
"P50": 95,
"P90": 109,
"P99": 130,
"P99.9": 213,
"max": 7654
}
}
}