1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-28 13:48:49 +08:00
Mirko Teodorovic bfd12304ac NOISSUE - update mqtt benchmark (#824)
* update gitignore

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* fix dates for cert

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* reorganize code

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* update docs

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* print to stdout for creating result file from script

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add script for testing

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add time measeuring

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* separate test in one file each

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* move config.toml

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* update docs

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add connection check, and prevent blocking of publisher when connection fails

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-08-27 14:21:39 +02:00
..

MQTT benchmarking tool

A simple MQTT (broker) benchmarking tool for Mainflux platform. ( based on github.com/krylovsk/mqtt-benchmark )

The tool supports multiple concurrent clients, publishers and subscribers configurable message size, etc:

cd benchmark
go build  -o mqtt-bench *.go

> mqtt-bench --help
Flags:
  -b, --broker string     address for mqtt broker, for secure use tcps and 8883 (default "tcp://localhost:1883")
      --ca string         CA file (default "ca.crt")
      --channels string   config file for channels (default "channels.toml")
  -g, --config string     config file default is config.toml (default "config.toml")
  -n, --count int         Number of messages sent per publisher (default 100)
  -f, --format string     Output format: text|json (default "text")
  -h, --help              help for mqtt-bench
      --msg string        messg to be sent, SENML (default "{\"n\":\"current\",\"t\":-4,\"v\":1.3}")
  -m, --mtls              Use mtls for connection
      --pubs int          Number of publishers (default 10)
  -q, --qos int           QoS for published messages, values 0 1 2
      --quiet             Supress messages
  -r, --retain            Retain mqtt messages
  -s, --size int          Size of message payload bytes (default 100)
  -t, --skipTLSVer        Skip tls verification
      --subs int          Number of subscribers (default 10)

Two output formats supported: human-readable plain text and JSON.

Before use you need a channels.toml you can use tools/provision/main.go to create channels for testing

Example use and output:

go build -o mqtt-bench *.go

without mtls
./mqtt-bench --broker tcp://localhost:1883 --count 100 --size 100  --qos 0 --format text   --subs 100 --pubs 0 --channels channels.toml

with mtls
./mqtt-bench --broker tcps://localhost:8883 --count 100 --size 100  --qos 0 --format text   --subs 100 --pubs 0 --channels channels.toml --mtls -ca ca.crt

You can use config.toml to create tests with this tool

./mqtt-bench --config config.toml it will read params from config.toml
broker_url = "tcp://localhost:1883"
qos = 2
message_size =100
message_count =100
publishers_num =3
subscribers_num =1
format = "text"
quiet = true
mtls = false
skiptlsver = true
ca_file = "ca.crt"
channels_file = "channels.toml"

You can use script which will run series of tests using mqtt-bench

cd tools/mqtt-bench/scripts
./mqtt-bench.sh mainflux mainflux.com channels.toml

For Example

./mqtt-benchmark --config tests/fanin.toml