NATS streaming - obsolete
užitečné příkazy
vystartování lokální instance v dockeru
docker rm nats-server; docker run -p 4222:4222 -p 8222:8222 -p 6222:6222 --name nats-server -ti nats:latest -m 8222 --jetstream
benchmark
Warning
Zastaralé! Většina benchmarků je z legacy STAN storage streaming backendu, který byl nahrazen JetStream backendem. Konkrétně pouze ODROID M1 benchmark používal nový JetStream backend, ale zároveň byl prováděn pouze vzdáleně, takže výsledky zahrnují i síťové přenosy a latence.
Příprava:
export GOPATH="$HOME/go"
mkdir -p $GOPATH
go get github.com/nats-io/gnatsd
go get github.com/nats-io/nats-streaming-server
go get github.com/nats-io/stan.go/
cd $GOPATH/src/github.com/nats-io/nats-streaming-server
go build
mkdir -p ~/nats ; ln -s ~/nats /tmp/STAN_TEST
./nats-streaming-server -c $GOPATH/src/github.com/nats-io/stan.go/examples/stan-bench/filestore.conf
cd $GOPATH/src/github.com/nats-io/stan.go/examples/stan-bench/
go build
./stan-bench -np 1 -ns 1 -n 100000 -ms 1024 bar
výsledky
RPi 3B+
USB NVME 240GB:
./stan-bench -np 1 -ns 1 -n 10000 -ms 1024 bar
Starting benchmark [msgs=10000, msgsize=1024, pubs=1, subs=1]
NATS Streaming Pub/Sub stats: 20,009 msgs/sec ~ 19.54 MB/sec
Pub stats: 10,003 msgs/sec ~ 9.77 MB/sec
Sub stats: 10,741 msgs/sec ~ 10.49 MB/sec
./stan-bench -np 1 -ns 1 -n 10000 -ms 1024 -sync bar
Starting benchmark [msgs=10000, msgsize=1024, pubs=1, subs=1]
NATS Streaming Pub/Sub stats: 1,528 msgs/sec ~ 1.49 MB/sec
Pub stats: 763 msgs/sec ~ 763.95 KB/sec
Sub stats: 18,661 msgs/sec ~ 18.22 MB/sec
SD 32GB:
./stan-bench -np 1 -ns 1 -n 100000 -ms 1024 bar
Starting benchmark [msgs=100000, msgsize=1024, pubs=1, subs=1]
NATS Streaming Pub/Sub stats: 18,206 msgs/sec ~ 17.78 MB/sec
Pub stats: 9,103 msgs/sec ~ 8.89 MB/sec
Sub stats: 9,128 msgs/sec ~ 8.91 MB/sec
./stan-bench -np 1 -ns 1 -n 10000 -ms 1024 -sync bar
Starting benchmark [msgs=10000, msgsize=1024, pubs=1, subs=1]
NATS Streaming Pub/Sub stats: 1,634 msgs/sec ~ 1.60 MB/sec
Pub stats: 816 msgs/sec ~ 816.98 KB/sec
Sub stats: 18,459 msgs/sec ~ 18.03 MB/sec
RPi 4B 8GB armhf
SD 200GB:
./stan-bench -np 1 -ns 1 -n 100000 -ms 1024 bar
Starting benchmark [msgs=100000, msgsize=1024, pubs=1, subs=1]
NATS Streaming Pub/Sub stats: 38,921 msgs/sec ~ 38.01 MB/sec
Pub stats: 19,460 msgs/sec ~ 19.00 MB/sec
Sub stats: 23,682 msgs/sec ~ 23.13 MB/sec
./stan-bench -np 1 -ns 1 -n 10000 -ms 1024 -sync bar
Starting benchmark [msgs=10000, msgsize=1024, pubs=1, subs=1]
NATS Streaming Pub/Sub stats: 3,792 msgs/sec ~ 3.70 MB/sec
Pub stats: 1,895 msgs/sec ~ 1.85 MB/sec
Sub stats: 34,892 msgs/sec ~ 34.07 MB/sec
ODROID C4
USB NVME:
./stan-bench -np 1 -ns 1 -n 100000 -ms 1024 bar
Starting benchmark [msgs=100000, msgsize=1024, pubs=1, subs=1]
NATS Streaming Pub/Sub stats: 58,932 msgs/sec ~ 57.55 MB/sec
Pub stats: 29,465 msgs/sec ~ 28.78 MB/sec
Sub stats: 32,168 msgs/sec ~ 31.41 MB/sec
./stan-bench -np 1 -ns 1 -n 10000 -ms 1024 -sync bar
Starting benchmark [msgs=10000, msgsize=1024, pubs=1, subs=1]
NATS Streaming Pub/Sub stats: 3,299 msgs/sec ~ 3.22 MB/sec
Pub stats: 1,649 msgs/sec ~ 1.61 MB/sec
Sub stats: 55,871 msgs/sec ~ 54.56 MB/sec
./stan-bench -np 1 -ns 1 -n 100000 -ms 1024 bar
Starting benchmark [msgs=100000, msgsize=1024, pubs=1, subs=1]
NATS Streaming Pub/Sub stats: 59,161 msgs/sec ~ 57.77 MB/sec
Pub stats: 29,580 msgs/sec ~ 28.89 MB/sec
Sub stats: 29,661 msgs/sec ~ 28.97 MB/sec
./stan-bench -np 1 -ns 1 -n 10000 -ms 1024 -sync bar
Starting benchmark [msgs=10000, msgsize=1024, pubs=1, subs=1]
NATS Streaming Pub/Sub stats: 3,366 msgs/sec ~ 3.29 MB/sec
Pub stats: 1,683 msgs/sec ~ 1.64 MB/sec
Sub stats: 61,537 msgs/sec ~ 60.10 MB/sec
ODROID M1
Nelze srovnávat, nová verze NATS s Jetstream storage a benchmark v nats cli toolu. Benchmark navíc proveden vzdáleně proti NATS v kubernetes (takže reálná performance). Všechny testy s 1KB velkou zprávou.
E2E latence request-reply
průměrná latence 629 µs
nats --server=nats://piks01:4222 bench foo --pub 1 --request --msgs 10000
21:35:28 Benchmark in request-reply mode
21:35:28 Starting request-reply benchmark [subject=foo, multisubject=false, multisubjectmax=0, request=true, reply=false, msgs=10,000, msgsize=128 B, pubs=1, subs=0, pubsleep=0s, subsleep=0s]
21:35:28 Starting publisher, publishing 10,000 messages
Finished 6s
Pub stats: 1,589 msgs/sec ~ 198.69 KB/sec
publish=5 subscribe=20 jetstream
NATS Pub/Sub stats: 81,983 msgs/sec ~ 80.06 MB/sec
nats --server=nats://piks01:4222 bench foo --pub 5 --sub 20 --size 1024 --js
21:27:17 [[JetStream]] ephemeral ordered push consumer mode, subscribers will not acknowledge the consumption of messages
21:27:17 Starting [[JetStream]] benchmark [subject=foo, multisubject=false, multisubjectmax=0, js=true, msgs=100,000, msgsize=1.0 KiB, pubs=5, subs=20, stream=benchstream, maxbytes=1.0 GiB, storage=memory, syncpub=false, pubbatch=100, jstimeout=30s, pull=false, consumerbatch=100, push=false, consumername=natscli-bench, replicas=1, purge=false, pubsleep=0s, subsleep=0s, dedup=false, dedupwindow=2m0s]
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting subscriber, expecting 100,000 messages
21:27:17 Starting publisher, publishing 20,000 messages
21:27:17 Starting publisher, publishing 20,000 messages
21:27:17 Starting publisher, publishing 20,000 messages
21:27:17 Starting publisher, publishing 20,000 messages
21:27:17 Starting publisher, publishing 20,000 messages
NATS Pub/Sub stats: 81,983 msgs/sec ~ 80.06 MB/sec
Pub stats: 3,922 msgs/sec ~ 3.83 MB/sec
[1] 796 msgs/sec ~ 796.60 KB/sec (20000 msgs)
[2] 794 msgs/sec ~ 794.22 KB/sec (20000 msgs)
[3] 788 msgs/sec ~ 788.25 KB/sec (20000 msgs)
[4] 785 msgs/sec ~ 785.73 KB/sec (20000 msgs)
[5] 784 msgs/sec ~ 784.53 KB/sec (20000 msgs)
min 784 | avg 789 | max 796 | stddev 4 msgs
Sub stats: 78,079 msgs/sec ~ 76.25 MB/sec
[1] 3,912 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[2] 3,909 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[3] 3,910 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[4] 3,914 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[5] 3,912 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[6] 3,908 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[7] 3,916 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[8] 3,915 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[9] 3,910 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[10] 3,914 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[11] 3,905 msgs/sec ~ 3.81 MB/sec (100000 msgs)
[12] 3,916 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[13] 3,912 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[14] 3,911 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[15] 3,906 msgs/sec ~ 3.81 MB/sec (100000 msgs)
[16] 3,914 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[17] 3,909 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[18] 3,904 msgs/sec ~ 3.81 MB/sec (100000 msgs)
[19] 3,910 msgs/sec ~ 3.82 MB/sec (100000 msgs)
[20] 3,907 msgs/sec ~ 3.82 MB/sec (100000 msgs)
min 3,904 | avg 3,910 | max 3,916 | stddev 3 msgs