105 Rti 2.6
105 Rti 2.6
Abstract— Internet of Things (IoT) solutions connect large messages generated by the end devices [2]. Message queuing
numbers of devices, which generate various data and control technologies which are available today differ in terms of the
messages asynchronously. In the IoT system cloud, these performance guarantees they offer, and depending on the
messages need to be queued in order to control the processing actual use-case, metrics such as latency, disk space, RAM
load and prevent the overload in cases of traffic bursts. On the memory or processor usage may be a limiting factor [2], [3].
other hand, one of the requirements the IoT cloud needs to fulfill
is the high availability. Therefore, multiple instances of services The comparison of Kafka and Apache Pulsar has been
accepting and processing the messages generated by the devices performed by the authors in [4], and it has been shown that,
are needed. There are various message queue technologies although Apache Pulsar may achieve better results in terms of
available today, but they all have their limitations. In this paper, resource usage, the maturity of the solution, available
we compare the performance of Apache Kafka and RabbitMQ in documentation, and possibility to integrate with other data
the scenario of the highly available IoT cloud data processing. processing tools, may be a reason to favor Kafka in the
commercial deployment scenarios. On the other hand, Kafka
Index Terms— message queue; high availability; load
balancing; internet of things. and RabbitMQ have been compared in [5], to show that
RabbitMQ has its advantages in terms of the achieved
throughput on a single server instance, but the scaling options
I. INTRODUCTION are on Kafka’s side.
In this paper, we explore the possibility of replacing the
In the past decade, the world is witnessing the expansion of
already implemented RabbitMQ message queueing within the
Internet of Things (IoT) solutions. Within IoT systems,
smart home system cloud [6],[7], with Apache Kafka. Within
different devices are connected to perform a certain function
the deployed smart home cloud, messages generated by end
together. IoT use-cases are various, such as smart transport,
devices are processed by multiple cloud services. As the
smart fabrics, smart cities, smart homes, etc.
number of supported features is growing, so is the number of
In order to collaborate, the devices need to be able to
the cloud services that process these messages. Also, some of
exchange data such as commands and state change reports.
the messages need to be processed by multiple of these
Although the expansion of IoT has led to the development of
services. Additionally, as the number of users grows, the
technologies such as ZigBee, Z-Wave, WiFi or Bluetooth
system needs to be scaled up, and, as already said, Kafka has
Low Energy, which enabled the connection of many different
its advantages in this domain. The paper is organized as
actuators and sensors into large local mesh networks, in order
follows: in Section II, the elements of smart home system and
for an IoT solution to achieve its purpose, the existence of the
its cloud architecture are introduced, then the overview of
cloud component is also needed. The cloud allows remote
RabbitMQ and Kafka is given in Section III and Section IV.
control and monitoring of the local networks, but it can also
Finally, the performed tests and their results are presented in
provide advanced features which require processing of larger
Section V.
quantities of historical system data, or the interaction with
components responsible for customer management, software
II. SMART HOME CLOUD DATA BUFFERING
update and third-party services.
As the data from the IoT system is generated In the existing smart home solution, the end devices within
asynchronously [1], and processing it requires a certain the household use technologies such as ZigBee, Z-Wave and
amount of time, mechanisms are needed to control the cloud ONVIF/IP to connect to the home gateway – Fig. 1. The
load. Usually, this control is achieved by deploying various gateway is responsible to execute the core system logic: it
message queueing systems, that allow to communicate implements the middleware which represents all of the
between different components of the cloud, and react to devices in the same way, regardless of the communication
technology they use in the local network, and allows them to
work together, according to the automation rules set up by the
Marko Milosavljević is with OBLO Living, Novi Sad, Narodnog fronta
21a, Serbia (e-mail: marko.a.milosavljevic@ obloliving.com).
user. To communicate with the user applications and cloud
Milica Matić is with the Faculty of Technical Sciences, University of Novi backend, the gateway uses MQTT protocol. MQTT conveys
Sad, Serbia (e-mail: [email protected]). commands issued by the user, system control messages, and
Neven Jović is with OBLO Living, Novi Sad, Narodnog fronta 21a, Serbia
reports about device state changes. Control messages are
(e-mail: neven.jovic@ obloliving.com).
Marija Antić is with the Faculty of Technical Sciences, University of Novi processed on the cloud side, for the purpose of system
Sad, Serbia (e-mail: [email protected]).
RTI2.6 Page 1 of 4
administration, upgrade, backup and restore. Also, reports it for processing. Message queuing allows web servers to
about device state changes are stored to provide user with the avoid the overload, as they can control the number of the
information about the history of system usage [7]. messages that are processed simultaneously. It is also useful
for distributing messages to multiple consumers sharing the
load and providing fault tolerance.
RTI2.6 Page 2 of 4
Similar to RabbitMQ, the Apache Kafka clients can act as presented in Table I.
producers and consumers – Fig. 3. Producers represent client RabbitMQ reached CPU limit after 16 consumers, but was
applications that write (publish) events to Kafka. On the other able to continue working stably, while the setup with 32
hand, consumers are subscribing to topics, reading and writing consumers stopped working after ten minutes. The throughput
events. Producers and consumers are not aware of each other. of the system was approximately 11000 messages per second.
They work completely independently, and that is a key design Maximum CPU usage was 800%, i.e. all eight cores were
to achieve high scalability. Therefore, producers will never used 100%.
need to wait for consumers. To test Kafka performance, 16 producers were created,
When data is written to Kafka, it is written in the form of an which published to the variable number of partitions (32, 64,
event containing the key, value, timestamp and optional 128). Since Kafka allows only one consumer per partition, the
metadata. Events are stored in topics. The durability of events number of consumers was also varied from 0 to 128. Test
inside Kafka’s topic is configurable. Unlike RabbitMQ, Kafka results are presented in Table II.
events can be read whenever they are needed, because events In any of test cases limit of Kafka maximum CPU load was
are not deleted after consumptions. Events can be stored as not reached. It can be observed that the CPU usage deviation
long as needed. Storing data for a long time does not affect is smaller than in RabbitMQ case. Therefore, the server stays
Kafka. stable, even as the number of messages that are stored in
Topics in Kafka are partitioned, and one Kafka topic can Kafka increases with time.
have any number of partitions defined in the Kafka
configuration file. Events are ordered inside the partition in TABLE II
KAFKA TEST RESULTS
the exactly same order as they were written, and one
consumer can process data from one partition only. However,
the data stored in one partition can be processed by multiple CPU usage on 8 cores [%]
Setup
average maximum deviation
consumers belonging to different consumer groups, i.e. one
16 producers
message can be processed multiple times, without the need to 32 partitions 210 573 65
duplicate it. Offset is an integer number that is used to 0 consumers
maintain the current position of a consumer inside partition. 16 producers
Every topic can be replicated, so that there are dozens of 32 partitions 202 347 43
32 onsumers
brokers that have a copy of data. This makes data fault- 16 producers
tolerant and highly-available. 64 partitions 186 473 90
0 consumers
III. TESTING AND RESULTS 16 producers
64 partitions 208 360 37
Tests were designed to measure CPU load of smart home 64 consumers
system servers when RabbitMQ and Apache Kafka are used 16 producers
for data buffering. RabbitMQ and Kafka brokers were run on 128 partitions 150 300 93
0 consumers
the 8-core Intel i7 processor with 8 GB of RAM memory. 16 producers
128 partitions 480 553 53
TABLE I 128 consumers
RABBITMQ TEST RESULTS
RTI2.6 Page 3 of 4
V. ACKNOWLEDGMENT [4] S. Intorruk and T. Numnonda, “A Comparative Study on Performance
and Resource Utilization of Real-time Distributed Messaging Systems
This research (paper) has been supported by the Ministry of for Big Data,” Proc. of IEEE/ACIS International Conference on
Education, Science and Technological Development through Software Engineering, Artificial Intelligence, Networking and
Parallel/Distributed Computing (SNPD), July 2019
the project no. 451-03-68/2020-14/200156: “Innovative [5] P. Dobbelaere and K. S. Esmaili, “Kafka versus RabbitMQ: A
scientific and artistic research from the FTS (activity) comparative study of two industry reference publish/subscribe
domain”. implementations: Industry Paper,” Proceedings of the 11th ACM
International Conference on Distributed and Event-based Systems
(DEBS '17), June 2017
REFERENCES [6] M. Matić, E. Nan, M. Antić, S. Ivanović and R. Pavlović, “Model-
[1] F. Metzger, T. Hoßfeld, A. Bauer, S. Kounev and P. E. Heegaard, Based Load Testing in the IoT System,” Proc. of International
“Modeling of Aggregated IoT Traffic and Its Application to an IoT Conference on Consumer Electronics (ICCE-Berlin), Sept. 2019
Cloud,” Proceedings of the IEEE, vol. 107, no. 4, pp. 679-694, April [7] S. Ivanović, M. Antić, I. Papp, N. Jović, “Data Acquisition, Collection
2019 and Storage in Smart Home Solutions,” Proc. of 6th International
[2] G. Fu, Y. Zhang and G. Yu, “A Fair Comparison of Message Queuing Conference on Electrical, Electronic and Computing Engineering
Systems,” IEEE Access, vol. 9, pp. 421-432, Jan. 2021 (IcETRAN), May 2019
[3] H. Wu, Z. Shang and K. Wolter, “Performance Prediction for the
Apache Kafka Messaging System,” Proc. of IEEE
HPCC/SmartCity/DSS, Aug. 2019
RTI2.6 Page 4 of 4