diff --git a/README.md b/README.md index 520f9cc..c4fd75b 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ sudo yum install libatomic ``` sh # ubuntu 20.04 -sudo apt install libatomic1 +sudo apt install libatomic1 ``` ### make @@ -61,27 +61,27 @@ Usage: emqtt_bench conn [--help ] [-d ] [-h []] --help help information -d, --dist enable distribution port - -h, --host mqtt server hostname or comma-separated + -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] -Q, --qoe Enable QoE tracking [default: false] - -i, --interval interval of connecting to the broker + -i, --interval interval of connecting to the broker [default: 10] -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 session [default: true] - -x, --session-expiry Set 'Session-Expiry' for persistent sessions + -x, --session-expiry Set 'Session-Expiry' for persistent sessions (seconds) [default: 0] - -S, --ssl ssl socoket for connecting to server + -S, --ssl ssl socket for connecting to server [default: false] --cacertfile CA certificate for server verification - --certfile client certificate for authentication, if + --certfile client certificate for authentication, if required by server - --keyfile client private key for authentication, if + --keyfile client private key for authentication, if required by server --quic QUIC transport [default: false] --load-qst load quic session tickets from dets file @@ -89,23 +89,23 @@ Usage: emqtt_bench conn [--help ] [-d ] [-h []] --prefix client id prefix -s, --shortids use short ids for client ids [default: false] -l, --lowmem enable low mem mode, but use more CPU - --num-retry-connect number of times to retry estabilishing a + --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 + -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 + --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, + --log_to Control where the log output goes. console: + directly to the console null: quietly, don't output any logs. [default: console] --prometheus Enable metrics collection via Prometheus. Usually used with --restapi to enable scraping endpoint. - --restapi Enable REST API for monitoring and control. - For now only serves /metrics. + --restapi Enable REST API for monitoring and control. + For now only serves /metrics. Can be set to IP:Port to listen on a specific IP and Port, or just Port to listen on all interfaces on that port. [default: disabled] @@ -138,13 +138,13 @@ Usage: emqtt_bench sub [--help ] [-d ] [-h []] [-p []] [ -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 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 + -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. + --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] @@ -153,7 +153,7 @@ Usage: emqtt_bench sub [--help ] [-d ] [-h []] [-p []] [ -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] + -S, --ssl ssl socket for connecting to server [default: false] --cacertfile CA certificate for server verification --certfile client certificate for authentication, if required by server --keyfile client private key for authentication, if required by server @@ -161,25 +161,25 @@ Usage: emqtt_bench sub [--help ] [-d ] [-h []] [-p []] [ --quic QUIC transport [default: false] --load-qst load quic session tickets from dets file --ifaddr local ipaddress or interface address - --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 + --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 + -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: + --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 + --log_to Control where the log output goes. console: directly to the console null: quietly, don't output any logs. [default: console] --prometheus Enable metrics collection via Prometheus. Usually used with --restapi to enable scraping endpoint. - --restapi Enable REST API for monitoring and control. - For now only serves /metrics. + --restapi Enable REST API for monitoring and control. + For now only serves /metrics. Can be set to IP:Port to listen on a specific IP and Port, or just Port to listen on all interfaces on that port. [default: disabled] @@ -213,15 +213,15 @@ Usage: emqtt_bench pub [--help ] [-d ] [-h []] [-p []] [ -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 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 + -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 - --payload-hdrs If set, add optional payload headers. cnt64: strictly increasing counter(64bit) per publisher + --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 @@ -232,7 +232,7 @@ Usage: emqtt_bench pub [--help ] [-d ] [-h []] [-p []] [ -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] + -S, --ssl ssl socket for connecting to server [default: false] --cacertfile CA certificate for server verification --certfile client certificate for authentication, if required by server --keyfile client private key for authentication, if required by server @@ -240,32 +240,32 @@ Usage: emqtt_bench pub [--help ] [-d ] [-h []] [-p []] [ --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. 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 + --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 + -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 + -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 + --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 + --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. + --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, + --log_to Control where the log output goes. console: directly to the console null: quietly, don't output any logs. [default: console] --prometheus Enable metrics collection via Prometheus. Usually used with --restapi to enable scraping endpoint. - --restapi Enable REST API for monitoring and control. - For now only serves /metrics. + --restapi Enable REST API for monitoring and control. + For now only serves /metrics. Can be set to IP:Port to listen on a specific IP and Port, or just Port to listen on all interfaces on that port. [default: disabled] diff --git a/README_FOR_DOCKER.md b/README_FOR_DOCKER.md index f949c95..33d500b 100644 --- a/README_FOR_DOCKER.md +++ b/README_FOR_DOCKER.md @@ -30,7 +30,7 @@ Usage: emqtt_bench conn [--help ] [-h []] [-p []] -P, --password password for connecting to server -k, --keepalive keep alive in seconds [default: 300] -C, --clean clean session [default: true] - -S, --ssl ssl socoket for connecting to server [default: false] + -S, --ssl ssl socket for connecting to server [default: false] --certfile client certificate for authentication, if required by server --keyfile client private key for authentication, if required by @@ -70,14 +70,14 @@ Usage: emqtt_bench sub [--help ] [-h []] [-p []] -P, --password password for connecting to server -k, --keepalive keep alive in seconds [default: 300] -C, --clean clean start [default: true] - -S, --ssl ssl socoket for connecting to server [default: false] + -S, --ssl ssl socket 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] --ifaddr local ipaddress or interface address ``` -For example, create 50K concurrent connections at the arrival rate of 100/sec: +For example, create 50K concurrent connections at the arrival rate of 100/sec: ```sh docker run -it emqtt_bench sub -c 50000 -i 10 -t bench/%i -q 2 @@ -113,7 +113,7 @@ Usage: emqtt_bench pub [--help ] [-h []] [-p []] -r, --retain retain message [default: false] -k, --keepalive keep alive in seconds [default: 300] -C, --clean clean start [default: true] - -S, --ssl ssl socoket for connecting to server [default: false] + -S, --ssl ssl socket 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] diff --git a/src/emqtt_bench.erl b/src/emqtt_bench.erl index 8269d03..19b0c8b 100644 --- a/src/emqtt_bench.erl +++ b/src/emqtt_bench.erl @@ -105,7 +105,7 @@ {limit, $L, "limit", {integer, 0}, "The max message count to publish, 0 means unlimited"}, {ssl, $S, "ssl", {boolean, false}, - "ssl socoket for connecting to server"}, + "ssl socket for connecting to server"}, {cacertfile, undefined, "cacertfile", string, "CA certificate for server verification"}, {certfile, undefined, "certfile", string, @@ -201,7 +201,7 @@ {expiry, $x, "session-expiry", {integer, 0}, "Set 'Session-Expiry' for persistent sessions (seconds)"}, {ssl, $S, "ssl", {boolean, false}, - "ssl socoket for connecting to server"}, + "ssl socket for connecting to server"}, {cacertfile, undefined, "cacertfile", string, "CA certificate for server verification"}, {certfile, undefined, "certfile", string, @@ -271,7 +271,7 @@ {expiry, $x, "session-expiry", {integer, 0}, "Set 'Session-Expiry' for persistent sessions (seconds)"}, {ssl, $S, "ssl", {boolean, false}, - "ssl socoket for connecting to server"}, + "ssl socket for connecting to server"}, {cacertfile, undefined, "cacertfile", string, "CA certificate for server verification"}, {certfile, undefined, "certfile", string, @@ -1492,7 +1492,7 @@ maybe_start_restapi(disabled) -> maybe_start_restapi("disabled") -> ok; maybe_start_restapi(RestAPI) -> - {IP, Port} = + {IP, Port} = case string:split(RestAPI, ":") of [IP0, Port0] -> {Port1, _} = string:to_integer(Port0),