Skip to content

Commit

Permalink
Merge pull request #200 from qzhuyan/dev/william/add-payload-headers
Browse files Browse the repository at this point in the history
chore(README): update for usages.
  • Loading branch information
qzhuyan authored Dec 23, 2022
2 parents fe2c789 + f3b7f4b commit 6fb25cb
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 119 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ jobs:
- uses: actions/checkout@v1
- name: prepare
run: |
brew update
brew install curl zip unzip gnu-sed kerl unixodbc freetds
echo "/usr/local/bin" >> $GITHUB_PATH
git config --global credential.helper store
Expand Down
193 changes: 78 additions & 115 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,66 +111,56 @@ For example, create 50K concurrent connections at the arrival rate of 100/sec:
```sh
$ ./emqtt_bench sub --help
Usage: emqtt_bench sub [--help <help>] [-d <dist>] [-h [<host>]]
[-p [<port>]] [-V [<version>]] [-c [<count>]]
[-n [<startnumber>]] [-i [<interval>]]
[-t <topic>] [-q [<qos>]]
[--load-qst <nst_dets_file>] [-Q [<qoe>]]
[-u <username>] [-P <password>] [-k [<keepalive>]]
[-C [<clean>]] [-x [<expiry>]] [-S [<ssl>]]
[--certfile <certfile>] [--keyfile <keyfile>]
[--ws [<ws>]] [--quic [<quic>]]
[--ifaddr <ifaddr>] [--prefix <prefix>]
[-s [<shortids>]] [-l <lowmem>]
[--num-retry-connect [<num_retry_connect>]]
[-R [<conn_rate>]]
[--force-major-gc-interval [<force_major_gc_interval>]]
[--log_to [<log_to>]]
Usage: emqtt_bench sub [--help <help>] [-d <dist>] [-h [<host>]] [-p [<port>]] [-V [<version>]] [-c [<count>]]
[-n [<startnumber>]] [-i [<interval>]] [-t <topic>] [--payload-hdrs [<payload_hdrs>]] [-q [<qos>]]
[-Q [<qoe>]] [-u <username>] [-P <password>] [-k [<keepalive>]] [-C [<clean>]] [-x [<expiry>]]
[-S [<ssl>]] [--certfile <certfile>] [--keyfile <keyfile>] [--ws [<ws>]] [--quic [<quic>]]
[--load-qst <nst_dets_file>] [--ifaddr <ifaddr>] [--prefix <prefix>] [-s [<shortids>]] [-l <lowmem>]
[--num-retry-connect [<num_retry_connect>]] [-R [<conn_rate>]]
[--force-major-gc-interval [<force_major_gc_interval>]] [--log_to [<log_to>]]
--help help information
-d, --dist enable distribution port
-h, --host mqtt server hostname or comma-separated
hostnames [default: localhost]
-h, --host mqtt server hostname or comma-separated hostnames [default: localhost]
-p, --port mqtt server port number [default: 1883]
-V, --version mqtt protocol version: 3 | 4 | 5 [default: 5]
-c, --count max count of clients [default: 200]
-n, --startnumber start number [default: 0]
-i, --interval interval of connecting to the broker
[default: 10]
-n, --startnumber The start point when assigning sequence numbers to clients. This is useful when running
multiple emqtt-bench instances to test the same broker (cluster), so the start number can be
planned to avoid client ID collision [default: 0]
-i, --interval interval of connecting to the broker [default: 10]
-t, --topic topic subscribe, support %u, %c, %i variables
--payload-hdrs Handle the payload header from received message. Publish side must have the same option enabled
in the same order. cnt64: Check the counter is strictly increasing. ts: publish latency counting.
[default: ]
-q, --qos subscribe qos [default: 0]
-Q, --qoe Enable QoE tracking [default: false]
-u, --username username for connecting to server
-P, --password password for connecting to server
-k, --keepalive keep alive in seconds [default: 300]
-C, --clean clean start [default: true]
-x, --session-expiry Set 'Session-Expiry' for persistent sessions
(seconds) [default: 0]
-S, --ssl ssl socoket for connecting to server
[default: false]
--certfile client certificate for authentication, if
required by server
--keyfile client private key for authentication, if
required by server
-x, --session-expiry Set 'Session-Expiry' for persistent sessions (seconds) [default: 0]
-S, --ssl ssl socoket for connecting to server [default: false]
--certfile client certificate for authentication, if required by server
--keyfile client private key for authentication, if required by server
--ws websocket transport [default: false]
--quic QUIC transport [default: false]
--load-qst load quic session tickets from dets file
--load-qst load quic session tickets from dets file
--ifaddr local ipaddress or interface address
--prefix client id prefix
-s, --shortids use short ids for client ids [default: false]
--prefix Client ID prefix. If not provided '$HOST_bench_(pub|sub)_$RANDOM_$N' is used, where $HOST is
either the host name or the IP address provided in the --ifaddr option, $RANDOM is a random
number and $N is the sequence number assigned for each client. If provided, the $RANDOM suffix
will not be added.
-s, --shortids Use short client ID. If --prefix is provided, the prefix is added otherwise client ID is the
assigned sequence number. [default: false]
-l, --lowmem enable low mem mode, but use more CPU
--num-retry-connect number of times to retry estabilishing a
connection before giving up [default: 0]
-R, --connrate connection rate(/s), default: 0, fallback to
use --interval [default: 0]
--force-major-gc-interval interval in milliseconds in which a major GC
will be forced on the bench processes. a
value of 0 means disabled (default). this
only takes effect when used together with
--lowmem. [default: 0]
--log_to Control where the log output goes. console:
directly to the console null: quietly,
don't output any logs. [default: console]
--num-retry-connect number of times to retry estabilishing a connection before giving up [default: 0]
-R, --connrate connection rate(/s), default: 0, fallback to use --interval [default: 0]
--force-major-gc-interval interval in milliseconds in which a major GC will be forced on the bench processes. a value of
0 means disabled (default). this only takes effect when used together with --lowmem. [default:
0]
--log_to Control where the log output goes. console: directly to the console null: quietly, don't
output any logs. [default: console]
```
For example, create 50K concurrent connections at the arrival rate of 100/sec:
Expand All @@ -182,96 +172,69 @@ For example, create 50K concurrent connections at the arrival rate of 100/sec:
## Pub Benchmark
```sh
./emqtt_bench pub --help
Usage: emqtt_bench pub [--help <help>] [-d <dist>] [-h [<host>]]
[-p [<port>]] [-V [<version>]] [-c [<count>]]
[-n [<startnumber>]] [-i [<interval>]]
[-I [<interval_of_msg>]] [-u <username>]
[-P <password>] [-t <topic>] [-s [<size>]]
[-m <message>] [-q [<qos>]] [-Q [<qoe>]]
[--load-qst <nst_dets_file>] [-r [<retain>]]
[-k [<keepalive>]] [-C [<clean>]] [-x [<expiry>]]
[-L [<limit>]] [-S [<ssl>]]
[--certfile <certfile>] [--keyfile <keyfile>]
[--ws [<ws>]] [--quic [<quic>]]
[--ifaddr <ifaddr>] [--prefix <prefix>]
[-s [<shortids>]] [-l <lowmem>] [-F [<inflight>]]
[-w [<wait_before_publishing>]]
[--max-random-wait [<max_random_wait>]]
[--min-random-wait [<min_random_wait>]]
[--num-retry-connect [<num_retry_connect>]]
[-R [<conn_rate>]]
[--force-major-gc-interval [<force_major_gc_interval>]]
[--log_to [<log_to>]]
Usage: emqtt_bench pub [--help <help>] [-d <dist>] [-h [<host>]] [-p [<port>]] [-V [<version>]] [-c [<count>]]
[-n [<startnumber>]] [-i [<interval>]] [-I [<interval_of_msg>]] [-u <username>] [-P <password>]
[-t <topic>] [--payload-hdrs [<payload_hdrs>]] [-s [<size>]] [-m <message>] [-q [<qos>]]
[-Q [<qoe>]] [-r [<retain>]] [-k [<keepalive>]] [-C [<clean>]] [-x [<expiry>]] [-L [<limit>]]
[-S [<ssl>]] [--certfile <certfile>] [--keyfile <keyfile>] [--ws [<ws>]] [--quic [<quic>]]
[--load-qst <nst_dets_file>] [--ifaddr <ifaddr>] [--prefix <prefix>] [-s [<shortids>]] [-l <lowmem>]
[-F [<inflight>]] [-w [<wait_before_publishing>]] [--max-random-wait [<max_random_wait>]]
[--min-random-wait [<min_random_wait>]] [--num-retry-connect [<num_retry_connect>]]
[-R [<conn_rate>]] [--force-major-gc-interval [<force_major_gc_interval>]] [--log_to [<log_to>]]

--help help information
-d, --dist enable distribution port
-h, --host mqtt server hostname or comma-separated
hostnames [default: localhost]
-h, --host mqtt server hostname or comma-separated hostnames [default: localhost]
-p, --port mqtt server port number [default: 1883]
-V, --version mqtt protocol version: 3 | 4 | 5 [default:
5]
-V, --version mqtt protocol version: 3 | 4 | 5 [default: 5]
-c, --count max count of clients [default: 200]
-n, --startnumber start number [default: 0]
-i, --interval interval of connecting to the broker
[default: 10]
-I, --interval_of_msg interval of publishing message(ms)
[default: 1000]
-n, --startnumber The start point when assigning sequence numbers to clients. This is useful when running
multiple emqtt-bench instances to test the same broker (cluster), so the start number can be
planned to avoid client ID collision [default: 0]
-i, --interval interval of connecting to the broker [default: 10]
-I, --interval_of_msg interval of publishing message(ms) [default: 1000]
-u, --username username for connecting to server
-P, --password password for connecting to server
-t, --topic topic subscribe, support %u, %c, %i, %s
variables
-t, --topic topic subscribe, support %u, %c, %i, %s variables
--payload-hdrs If set, add optional payload headers. cnt64: strictly increasing counter(64bit) per publisher
ts: Timestamp when emit example: --payload-hdrs cnt64,ts [default: ]
-s, --size payload size [default: 256]
-m, --message set the message content for publish
-q, --qos subscribe qos [default: 0]
-Q, --qoe Enable QoE tracking [default: false]
-r, --retain retain message [default: false]
-k, --keepalive keep alive in seconds [default: 300]
-C, --clean clean start [default: true]
-x, --session-expiry Set 'Session-Expiry' for persistent
sessions (seconds) [default: 0]
-L, --limit The max message count to publish, 0 means
unlimited [default: 0]
-S, --ssl ssl socoket for connecting to server
[default: false]
--certfile client certificate for authentication, if
required by server
--keyfile client private key for authentication, if
required by server
-x, --session-expiry Set 'Session-Expiry' for persistent sessions (seconds) [default: 0]
-L, --limit The max message count to publish, 0 means unlimited [default: 0]
-S, --ssl ssl socoket for connecting to server [default: false]
--certfile client certificate for authentication, if required by server
--keyfile client private key for authentication, if required by server
--ws websocket transport [default: false]
--quic QUIC transport [default: false]
--load-qst load quic session tickets from dets file
--ifaddr One or multiple (comma-separated) source
IP addresses
--prefix client id prefix
-s, --shortids use short ids for client ids [default:
false]
--ifaddr One or multiple (comma-separated) source IP addresses
--prefix Client ID prefix. If not provided '$HOST_bench_(pub|sub)_$RANDOM_$N' is used, where $HOST is
either the host name or the IP address provided in the --ifaddr option, $RANDOM is a random
number and $N is the sequence number assigned for each client. If provided, the $RANDOM
suffix will not be added.
-s, --shortids Use short client ID. If --prefix is provided, the prefix is added otherwise client ID is the
assigned sequence number. [default: false]
-l, --lowmem enable low mem mode, but use more CPU
-F, --inflight maximum inflight messages for QoS 1 an 2,
value 0 for 'infinity' [default: 1]
-w, --wait-before-publishing wait for all publishers to have (at least
tried to) connected before starting
publishing [default: false]
--max-random-wait maximum randomized period in ms that each
publisher will wait before starting to
publish (uniform distribution) [default: 0]
--min-random-wait minimum randomized period in ms that each
publisher will wait before starting to
publish (uniform distribution) [default: 0]
--num-retry-connect number of times to retry estabilishing a
connection before giving up [default: 0]
-R, --connrate connection rate(/s), default: 0, fallback
to use --interval [default: 0]
--force-major-gc-interval interval in milliseconds in which a major
GC will be forced on the bench processes.
a value of 0 means disabled (default).
this only takes effect when used together
with --lowmem. [default: 0]
--log_to Control where the log output goes.
console: directly to the console
null: quietly, don't output any logs.
[default: console]
-F, --inflight maximum inflight messages for QoS 1 an 2, value 0 for 'infinity' [default: 1]
-w, --wait-before-publishing wait for all publishers to have (at least tried to) connected before starting publishing
[default: false]
--max-random-wait maximum randomized period in ms that each publisher will wait before starting to publish
(uniform distribution) [default: 0]
--min-random-wait minimum randomized period in ms that each publisher will wait before starting to publish
(uniform distribution) [default: 0]
--num-retry-connect number of times to retry estabilishing a connection before giving up [default: 0]
-R, --connrate connection rate(/s), default: 0, fallback to use --interval [default: 0]
--force-major-gc-interval interval in milliseconds in which a major GC will be forced on the bench processes. a value
of 0 means disabled (default). this only takes effect when used together with --lowmem.
[default: 0]
--log_to Control where the log output goes. console: directly to the console null: quietly,
don't output any logs. [default: console]
```
For example, create 100 connections and each publishes messages at the rate of 100 msg/sec.
Expand Down
6 changes: 3 additions & 3 deletions src/emqtt_bench.erl
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
"topic subscribe, support %u, %c, %i, %s variables"},
{payload_hdrs, undefined, "payload-hdrs", {string, ""},
" If set, add optional payload headers."
" cnt64: strict increasing counter(64bit) per publisher"
" cnt64: strictly increasing counter(64bit) per publisher"
" ts: Timestamp when emit"
" example: --payload_hdrs cnt64,ts"
" example: --payload-hdrs cnt64,ts"
},
{size, $s, "size", {integer, 256},
"payload size"},
Expand Down Expand Up @@ -155,7 +155,7 @@
{payload_hdrs, undefined, "payload-hdrs", {string, []},
"Handle the payload header from received message. "
"Publish side must have the same option enabled in the same order. "
"cnt64: Check the counter is strict increasing. "
"cnt64: Check the counter is strictly increasing. "
"ts: publish latency counting."
},
{qos, $q, "qos", {integer, 0},
Expand Down

0 comments on commit 6fb25cb

Please sign in to comment.