Skip to content

[Feature] The CLI adds a -L parameter to limit message size in the bench command #1360

@ysfscream

Description

@ysfscream

Ref: https://github.com/emqx/emqtt-bench

Image

Motivation

In the current version of MQTTX, when running the Publish Benchmark, users can run the mqttx bench pub command and define various parameters such as the number of clients and topics. However, there is no way to limit the number of published messages. This can lead to uncontrolled message flow and potential system overload. Users may be frustrated by the lack of control over the number of messages they are publishing.

Detailed design

To resolve this issue, I propose the addition of a -L (--limit) parameter for the "mqttx bench pub" command. This parameter will allow users to set a maximum limit for the number of published messages. Here is how it would look:

Parameter Description Default
-L, --limit The maximum number of messages to publish. A value of 0 means no limit on the number of messages. 0

If the --limit parameter is set to a value greater than 0, the command will publish up to the defined number of messages. If it's set to 0, there will be no limit to the number of messages published.

Example of use:

Command:

mqttx bench pub -c 5000 -t bench/%i -L 1000

Explanation: This command publishes data with MQTTX Bench where:

  • -c 5000 means that it uses 5000 clients,
  • -t bench/%i is the topic to which data is published,
  • -L 1000 limits the number of published messages to 1000.

Result:

The MQTTX Bench will publish up to 1000 messages to the topic bench/%i using 5000 clients. If the data to be published exceeds 1000 messages, it will stop sending further messages.

Alternatives

An alternative approach could be implementing a global setting for message limits that would apply to all "mqttx bench pub" commands. However, this would limit the flexibility of the command and may not be suitable for all use cases. Another alternative could be to ignore this feature, leading to issues with system overloads and reduced performance.

More detail (optional)

This feature requires modifications in how the "mqttx bench pub" command is implemented. It would need to consider the new --limit parameter and adjust the message publishing process accordingly.

Here's a simple flow diagram for better understanding:

Start -> Check if --limit > 0 -> If True, Limit the number of messages to --limit -> Continuously publish messages -> End
                                     |      
                                     -> If False, No limit on the number of messages -> Continuously publish messages

This feature enhances the control users have over their message flow, providing a more efficient and manageable way of using MQTTX.

Metadata

Metadata

Assignees

Labels

CLIMQTTX CLIfeatureThis pr is a feature

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions