Skip to content

Commit

Permalink
docs: Restructure autorate documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ieQu1 committed Jan 2, 2025
1 parent 3e5141a commit 66ceaf7
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
name: Install additional packages
run: |
apt-get update
apt-get install -y texinfo
apt-get install -y texinfo install-info
- name: Build
shell: bash
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ docs: doc/info/emqttb.info doc/html/index.html

doc/info/emqttb.info: $(TEXINFO)
texi2any -I doc/lee --info -o $@ $<
install-info $@ doc/info/dir

doc/html/index.html: $(TEXINFO)
# -c MATHJAX_CONFIGURATION="$(MATHJAX_OPTS)"
Expand Down
12 changes: 4 additions & 8 deletions bin/emqttb
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@ RUNNER_ROOT_DIR="{{ runner_root_dir }}"
RUNNER_ESCRIPT_DIR="{{ runner_escript_dir }}"
ERTS_VSN="{{ erts_vsn }}"

ERTS_PATH=$RUNNER_ROOT_DIR/erts-$ERTS_VSN/bin
ERTS_PATH="${RUNNER_ROOT_DIR}/erts-${ERTS_VSN}/bin"

export INFOPATH="${INFOPATH}:${RUNNER_ROOT_DIR}/doc/info"

ulimit -n $(ulimit -Hn)

help() {
local file
file="${RUNNER_ROOT_DIR}/doc/info/emqttb.info"
if command -v emacs; then
emacs -eval "(info \"${file}\")"
else
info "${file}" "${@}"
fi
info emqttb "${@}"
}

if [ $# -eq 2 ] && [ $1 = "--help" ]; then
Expand Down
46 changes: 46 additions & 0 deletions doc/src/autorate_descr.texi
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
When the loadgen creates too much traffic, the system may get overloaded.
In this case, the test usually has to be restarted all over again with different parameters.
This can be very expensive in man-hours and computing resources.

In order to prevent that, emqttb can tune some parameters (such as message publishing interval)
automatically using
@url{https://controlguru.com/integral-reset-windup-jacketing-logic-and-the-velocity-pi-form/,PI controller}.

The following formula is used for the error function:

@math{e=(a_{SP} - a_{PV}) a_{coeff}}

@node Autoscale
@section Autoscale

A special autorate controlling the rate of spawning new clients is implicitly created for each client group.
Its name usually follows the pattern @code{%scenario%/conn_interval}.

By default, the number of pending (unacked) connections is used as the process variable.
Number of pending connections is a metric that responds very fast to target overload, so it makes a reasonable default.

For example the following command can automatically adjust the rate of connections:

@example
./emqttb --pushgw @@conn -I 10ms -N 5_000 \
@@a -a conn/conninterval -V 1000 --setpoint 10
@end example

@node SCRAM
@section SCRAM

Normally, autorate adjusts the control variable gradually.
However, sometimes the system under test becomes overloaded suddenly, and in this case slowly decreasing the pressure may not be efficient enough.
To combat this situation, @code{emqttb} has "SCRAM" mechanism, that immediately resets the control variable to a @ref{value/autorate/_/scram/override,configured safe value}.
This happens when the value of process variable exceeds a @ref{value/autorate/_/scram/threshold,certain threshold}.

SCRAM mode remains in effect until the number of pending connections becomes less than @math{\frac{t h}{100}}
where @math{t} is threshold, and @math{h} is @ref{value/autorate/_/scram/hysteresis,hystersis}.

@node Autorate List
@section List of autorate variables
@include autorate.texi

@node Metrics List
@section List of metrics
@include metric.texi
64 changes: 44 additions & 20 deletions doc/src/emqttb.texi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
@setfilename emqttb.info
@settitle EMQTTB
@c %**end of header

@dircategory EMQTTB: an MQTT load generator.
@direntry
* EMQTTB: (emqttb).
@end direntry

@copying
A scriptable autotuning MQTT load generator.

Expand Down Expand Up @@ -32,33 +38,51 @@ Copyright @copyright{} 2022-2025 EMQ Technologies Co., Ltd. All Rights Reserved.
@insertcopying
@end ifnottex

@include intro.texi
@node Introduction
@chapter Introduction
@include intro.texi

@node Invokation
@chapter Invokation
@node CLI
@section CLI Arguments
@lowersections
@include cli_param.texi
@raisesections

@node OS Environment Variables
@section OS Environment Variables
@lowersections
@include os_env.texi
@raisesections
EMQTTB executable accepts named CLI arguments (such as @option{--foo} or -f positional arguments and actions. Actions are special CLI arguments that start with @@ character (e.g. @option{@@pub}). Actions correspond to different load-generation scenarios, such as @option{@@pub} and @option{@@sub}, client group configurations (@option{@@g}) and autorates (@option{@@g}).

@node All Values
@chapter All Configurable Values
@include value.texi
Each CLI action defines its own scope of named and positional CLI arguments. Positional arguments are always specified after named arguments within the scope. There is also a global scope of arguments that don’t belong to any action. Global arguments are specified before the very first action.

Example:

@example
emqttb --foo --bar 1 positional1 positional2 @@action1 --foo 1 positional1 @@action2 ...
|___________| |_____________________| |_________________|
|regular args positional args | action1 scope
|___________________________________|
global scope
@end example

Flag negation:

Boolean flag arguments can be set to false by adding @code{no-} prefix, for example @option{--no-pushgw}.

Short boolean flags can be set to false using @code{+} sigil instead of @code{-}.

@node CLI
@section CLI Arguments
@lowersections
@include cli_param.texi
@raisesections

@node OS Environment Variables
@section OS Environment Variables
@lowersections
@include os_env.texi
@raisesections

@node Autorate
@chapter List of autorate variables
@include autorate.texi
@chapter Autorate
@include autorate_descr.texi

@node Metrics
@chapter List of metrics
@include metric.texi
@node All Values
@chapter All Configurable Values
@include value.texi

@node Index
@unnumbered Index
Expand Down
14 changes: 12 additions & 2 deletions doc/src/intro.texi
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
@node Introduction
@chapter Introduction
@node Concepts
@section Concepts: Worker, Group, Scenario...

@b{Worker} is a process that corresponds to a single MQTT client.

@b{Behavior} is a callback module containing functions that workers run in a loop.

@b{Group} is a supervised colletion of workers running the same behavior and sharing the same configuration. Group manager controls the number of workers, restarts failed workers and implements ramp up/down logic.

@b{Scenario} is a callback module that creates several worker groups and manupulates group configuration using autorate.

@b{Autorate} a process that adjusts group parameters (such as number of workers in the group, or worker configuration) based on constants or dynamic parameters, e.g. available RAM or CPU load, observed latency and so on.

@node Topic Patterns
@section Topic Patterns
Expand Down
43 changes: 0 additions & 43 deletions doc/src/schema.texi
Original file line number Diff line number Diff line change
Expand Up @@ -30,49 +30,6 @@

@end macro

@macro doc-autorate
When the loadgen creates too much traffic, the system may get overloaded.
In this case, the test usually has to be restarted all over again with different parameters.
This can be very expensive in man-hours and computing resources.

In order to prevent that, emqttb can tune some parameters (such as message publishing interval)
automatically using
@url{https://controlguru.com/integral-reset-windup-jacketing-logic-and-the-velocity-pi-form/,PI controller}.

The following formula is used for the error function:

@math{e=(a_{SP} - a_{PV}) a_{coeff}}

@heading Autoscale
@cindex autoscale

A special autorate controlling the rate of spawning new clients is implicitly created for each client group.
Its name usually follows the pattern @code{%scenario%/conn_interval}.


By default, the number of pending (unacked) connections is used as the process variable.
Number of pending connections is a metric that responds very fast to target overload, so it makes a reasonable default.

For example the following command can automatically adjust the rate of connections:

@example
./emqttb --pushgw @@conn -I 10ms -N 5_000 \
@@a -a conn/conninterval -V 1000 --setpoint 10
@end example

@end macro

@macro doc-scram
Normally, autorate adjusts the control variable gradually.
However, sometimes the system under test becomes overloaded suddenly, and in this case slowly decreasing the pressure may not be efficient enough.
To combat this situation, @code{emqttb} has "SCRAM" mechanism, that immediately resets the control variable to a @ref{value/autorate/_/scram/override,configured safe value}.
This happens when the value of process variable exceeds a @ref{value/autorate/_/scram/threshold,certain threshold}.

SCRAM mode remains in effect until the number of pending connections becomes less than @math{\frac{t h}{100}}
where @math{t} is threshold, and FIXME @math{h} is @ref{value/autorate/_/scram/hysteresis,hystersis}.

@end macro

@macro doc-interval
Supported units:

Expand Down
2 changes: 1 addition & 1 deletion src/conf/emqttb_conf_model.erl
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ model() ->
, autorate =>
{[map, cli_action],
#{ oneliner => "Autorate configuration"
, doc => "@doc-autorate"
, doc => "@xref{Autorate}\n"
, cli_operand => "a"
, key_elements => [[id]]
},
Expand Down
6 changes: 3 additions & 3 deletions src/framework/emqttb_autorate.erl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ model() ->
#{ oneliner => "ID of the autorate configuration"
, doc => "Autorate identifier.
This value must be equal to one of the elements returned by @code{emqttb @@ls autorate} command.
Full list is also available in FIXME <<autorate>>
Full list is also available in @ref{Autorate List}.
"
, type => atom()
, default => default
Expand All @@ -144,7 +144,7 @@ model() ->
, doc => "This parameter specifies ID of the metric that senses pressure on the SUT and serves as the process variable (PV).
Its value must be equal to one of the metric IDs returned by @code{emqttb @@ls metric} command.
Full list can be also found in FIXME <<metrics>>.
Full list can be also found in @ref{Metrics List}.
"
, type => lee:model_key()
, cli_operand => "pvar"
Expand Down Expand Up @@ -223,7 +223,7 @@ model() ->
#{ enabled =>
{[value, cli_param],
#{ oneliner => "Enable SCRAM"
, doc => "@doc-scram"
, doc => "@xref{SCRAM}\n"
, type => boolean()
, default => false
, cli_operand => "olp"
Expand Down

0 comments on commit 66ceaf7

Please sign in to comment.