0.0
No commit activity in last 3 years
No release in over 3 years
mqtt benchmark for ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0

Runtime

~> 0.3
 Project Readme

ruby-mqtt-bench

mqtt-bench for ruby

This project is deeply inspired by mqtt-bench. Ruby cannot provide the same performance as golang. This code is provided just for debugging purposes.

Installation

gem install ruby-mqtt-bench

How to use

ruby-mqtt-bench conf/mqtt_bench.conf

Configuration

The configuration can be modified by editing mqtt_bench.conf as follows. mqtt_opts are passed to ruby-mqtt and bench_opts are used locally in ruby-mqtt-bench.

vi conf/mqtt_bench.conf
{
  "mqtt_opts": {
    "host": "127.0.0.1",
    "port": 1883,
    "keep_alive": 15
  },
  "bench_opts": {
    "topic": "mqtt_bench",
    "num_clients": 128,
    "data_size": 64,
    "num_msgs": 1000,
    "interval": 0,
    "time_key": "time",
    "timestamp": "timestamp"
  }
}
  • topic: topic to be published
  • num_clients: number of clients connecting to a target broker simultaneously
  • data_size: message size
  • num_msgs: total number of messages sent to a target broker
  • interval: message sending interval
  • time_key: attribute name of time when the message was published
  • timestamp: attribute name for passing timestamp information to fluentd (default nil)

Message is created in JSON format. Because each message has minimum fields, minimum message size can be calculated as follows:

Example message:

{:cid=>"001", :data=>"", :mid=>"00001", :time=>1455754303515}

Field name and symbols have 50 bytes. "data" field size can be specified in configuration. "cid" (client id) and "mid" (message id) have number of digits with maximum number specified in configuration (num_clients and num_msgs. Time to send a message is recorded in the message as time field in ms.