1. Introduction
Cardiovascular disease (CVD) is one of the leading causes of morbidity and mortality worldwide. According to the World Health Organization, cardiovascular diseases are the major cause of death, and as many as 56% of all deaths worldwide are caused by CVD [
1]. CVD is also categorized as a noncommunicable disease (NCDs), and it has been reported that in 2019, it has already accounted for 33.3 million deaths worldwide [
2]. CVD is the second major contributor to worldwide health cases, and, in the United States, sudden cardiac death (SCD) is projected to rise to 8.5 million by 2030 [
3]. CVD encompasses a range of conditions that affect the heart and blood vessels, including coronary artery disease, arrhythmias, and heart failure. The increasing CVD risk is driven by factors such as a sedentary lifestyle, poor diet, alcohol consumption, smoking, and an aging population [
4]. The worst consequence of CVD is sudden cardiac death caused by arrhythmia, a component of CVD that impairs the ability of the heart to pump blood [
5]. Therefore, a monitoring system for CVD is needed to reduce the mortality rate from CVD [
6], in addition to the improvement of lifestyle habits. The detection and continuous monitoring of the heart rhythm are crucial for preventing severe outcomes and improving patient care. However, traditional monitoring systems often lack mobility, scalability, and real-time capabilities, highlighting the need for innovative solutions powered by Internet of Things (IoT) technologies and cloud computing.
In this IoT-powered era, combined with the advancement of machine learning (ML) and cloud technology, there is an opportunity to help CVD patients monitor their health rhythm. The importance of health monitoring systems lies in the importance of reliable system design that can be relied on in terms of the data-processing speed and service availability. A good system design has an impact on providing real-time data from sensors, processing the data on the cloud, and delivering them to the users.
Previous research on heart rate monitoring systems has a system design that leverages protocol buffers (Protobuff) to serialize data [
7] as an interservice communication protocol in the Kubernetes cluster. This approach not only ensures high-speed data transfer but also reduces communication costs compared to text-based serialization. The combination of Kubernetes and ProtoBuff ensures improved scalability and stable CPU usage.
In addition, many systems emphasize the role of advanced sensor gateways in preprocessing data at the edge before forwarding them to the centralized cloud infrastructure. Message queuing telemetry transport (MQTT) and Advanced Message Queuing Protocol (AMQP) [
8] are protocols that are mostly used as sensor gateways because of their reliability and speed in transferring data from the sensor to the cloud environment. Even though there is no major difference between AMQP and MQTT [
9], these two protocols still have their advantages. For example, AMQP has the lowest jitter value, indicating that AMQP is more stable for handling large amounts of packets, and MQTT has the lowest CPU usage.
Previous research on heart rate monitoring systems has heavily utilized edge computing to process data closer to the source. By applying edge computing, these systems can take advantage of techniques such as caching at the edge to reduce latency [
10] and minimize the volume of data sent to the cloud. This approach enables near-real-time data processing while saving bandwidth and computing resources.
Despite the advantages of edge computing, this study adopts a different approach because of the limitations of small-scale monitoring devices. Implementing edge computing requires additional hardware and resources, which may not be feasible for compact, low-power heart rate monitoring devices. To address this, this study shifted all processing to the cloud, utilizing its scalability and computing power to handle real-time data streams. By bypassing the edge and centralizing the processing in the cloud, the system achieves greater simplicity and adaptability, making it more practical for small-scale devices. This research focuses on finding the most stable architecture to receive many requests at a time while still being able to provide responses to users in real time. To determine the performance of the architecture, a test hit can be performed on the existing architecture; however, during the test, there can be various latencies due to local traffic that may be shared with other users. This research does not further explain methods to secure patient data because it focuses on stable and real-time architecture. In addition, the proposed method is a solution that can use an architecture that can be applied to the cloud rather than existing edge computing solutions because it considers the flexibility of patients who will use this health monitoring, whereas the existing edge computing solution requires patients to bring additional devices and requires a continuous supply of energy to work. As such, this research focuses on optimizing the use of a more flexible cloud by providing a reliable and stable architecture for sending and receiving data. However, the cloud approach requires connection stability from the client side, and unstable internet conditions can also affect the speed of data processing.
In addition, some research has explored improving system performance by using a separate database for each service in a microservice architecture [
11]. This approach improved the execution time and modularity of the system. Other research implements event-driven architecture using messaging intermediaries, such as Apache Kafka, to facilitate efficient data flow and asynchronous communication between services. Although these methodologies offer significant advantages, they are often limited by the limitations of edge devices in terms of computing power and scalability.
Another study used more than one sensor gateway to improve latency and throughput by spreading the load between the sensor gateways rather than using only one sensor gateway [
12]. Each sensor gateway forwards the data to the message broker; an addition can be made to this research by changing the sensor gateway from HTTP to a lightweight protocol, such as MQTT or AMQP. A study proved that HTTP is not suitable for real-time data processing based on the comparison of latency and throughput [
13].
Kubernetes is an open-source project that aims for container orchestration. Kubernetes was used in this study because its performance is better than that of other orchestrators, such as K3s and KubeEdge. This is supported by research showing that Kubernetes has a lower memory footprint than other orchestrators [
14]. These advantages make Kubernetes suitable for use in this study and for scenarios that require high scalability.
Additionally, Kubernetes offers flexibility in container management through its built-in features. With a modular architecture and a wide ecosystem, Kubernetes allows integration with various tools [
15].
However, Kubernetes pose a new challenge of orchestration complexity; this challenge occurs because of the need for knowledge about load balancing configuration and service discovery. Resource allocation also needs to be considered to prevent wastage of resources due to underutilization or excessive overhead. In addition, performance overhead can occur in large-scale deployments, where networking, control planes, and the use of persistent storage can affect the response time.
From the comparison of MQTT, AMQP, and WebSocket protocols, WebSocket has poor performance compared with other protocols, as explained in studies that have shown that WebSocket has a weakness in latency for large payload sizes [
16]. In the same study, MQTT and AMQP exhibited decreased performance when using a high Quality of Service (QoS). Using several studies that have been conducted, this research aims to obtain the best system design using Kubernetes in a local environment. Kubernetes was used to provide scalability and ease of management for containerized applications, unlike traditional infrastructure that requires manual configuration and scaling. This study compares several microservice architectures deployed in a local Kubernetes cluster. The first architecture utilizes MQTT for the sensor gateway, where the goal is to place incoming data from sensors into the system and to maximize data flow; data from MQTT will be forwarded to a message broker using Apache Kafka and then routed to related services. The second architecture leverages the lightweight nature and speed of data transfer from MQTT, with data being directly forwarded to related services.
The metrics to be compared were latency, throughput, error rate, and RAM usage. From the architectures that were be compared, this research looks for the advantages and disadvantages of each architecture in the context of deploying machine learning in a Kubernetes environment for IoT systems.
3. Results
This section will explain the process of obtaining the best prediction model and comparison between the traditional architecture (MQTT) and the proposed architecture (MQTT Kafka) based on the metric evaluation that has been discussed.
3.2. Throughput Evaluation
The throughput value was obtained from the number of requests the server can handle in seconds. Each result obtained in this test was the result of an average of 30 trials that were carried out. In the test of 500 users, each user sent 20 ECG predictions; the test results show that with the traditional method, the highest throughput that could be achieved was 486 packets/s, which indicates that, in its best condition, the traditional method can receive 486 packets per second. The estimated time to complete 10,000 requests sent to the server was about 21 s.
In the proposed method, the highest throughput was 2210 packets/s, much higher than the traditional method, as seen in
Figure 11. This test shows that the proposed method can handle the number of requests better than the traditional method. The higher throughput also indicates the proposed method’s ability to complete requests faster, which takes about 5 s. This shows that the proposed method performs better than the traditional method.
In tests with a simulation of 500 users, each user sent 35 ECG predictions; the MQTT architecture had the most significant throughput of 486 packets/s, indicating that the MQTT architecture could send 486 packets in one second at the highest performance of the architecture, and with this total throughput, the traditional method took approximately 36 s to complete 17,500 packets. These test results prove the limitations on the performance of the traditional method with a higher number of requests.
As for the proposed method, the highest performance was 2085 packets/s, indicating that the proposed method has a performance that far exceeds the traditional method. The proposed method had four times a greater performance than the traditional method, as seen in
Figure 12. The proposed method took approximately 8 s to complete the total requests sent. Thus, the proposed method is much more efficient and can handle a larger volume of requests in a shorter time.
In a test with a simulation of 500 users, each user sent 50 ECG predictions; the results were using the traditional method; the highest throughput that could be achieved was 484 packets/s, as seen in
Figure 13; this result shows that there was no significant improvement in throughput from the previous test, indicating that the traditional method could not handle the spike in demand efficiently. This also indicates that the traditional method has limitations in terms of scalability when handling large numbers of requests.
For the proposed method, the average throughput achieved was 1587 packets/s. This performance decreased compared to the first test but still outperformed the traditional method. With this throughput, the proposed method could still handle spikes in requests with better efficiency. Nonetheless, the proposed method still shows its superiority in handling a larger volume of requests compared to the traditional method despite the slight decrease in performance.
Based on the results obtained from
Figure 11,
Figure 12 and
Figure 13, it is clear that there is a trend where the proposed method is superior to the traditional method. The proposed method beat the traditional method in terms of the amount of data handled simultaneously. The proposed method obtained a peak throughput of 2210 packets/s in the first scenario before decreasing slightly in the second and third scenarios to its lowest point of 1587 packets/s. At this point, the proposed method showed decreased performance due to increased resource requirements.
In the traditional method, throughput stagnated at 484–486 packets/s across the three scenarios, indicating a bottleneck in adapting to the number of incoming requests. In contrast, the proposed method could handle the number of requests because Apache Kafka can divide and handle many requests.
Figure 13 provides insight into the stability of the existing method. The proposed method can still maintain its advantage over the traditional method, but there is a performance degradation that can be caused by network congestion or additional processing time. The absence of an error plot in
Figure 13 limits the ability to analyze the variation and fluctuation of throughput. As an additional explanation, the white dots in the box plot above indicate the outliers of the data that are not within the distribution.
3.3. Response Evaluation
Response time measures the time it takes for data to reach the destination and return. This metric measures the time it takes to send the data and the time it takes for the server to process the data and send the response back to the user. The result was that 500 users sent 20 prediction requests to the server. For the proposed method, the best performance was at 0 ms, and the highest value was at 60 ms with an average response time of 0.12 ms, while for the traditional method, the best performance was at 0 ms, and the highest value was at 4 ms with an average response time of 0.09 ms. From the data, it can be seen that the traditional method can perform the better than proposed method. However, the difference in standard deviation between the traditional and proposed method shows significant results; the proposed method has a smaller number, which shows that the proposed method has a stable response time.
From the test results, it can be observed that the proposed method has an advantage in response time stability over the traditional method. This can be seen from the standard deviation difference between the two methods. This difference can be attributed to the optimization of processing the incoming data into the server and using an architecture that can handle many data streams efficiently.
When testing for 500 users, 35 prediction requests were sent to the server, showing the performance of the traditional method with the best response time value at 0 ms and the worst response time at 9 ms. This shows that with this enormous load, the traditional method can still handle the number of incoming requests very well, as seen from the worst time, which was only 9 ms, while the average response time was 0.05. Despite the increase in the previous test, the traditional method could still provide pretty good performance for real-time applications.
For the proposed method, the best response time was 0 ms, and the worst time was 234 ms; this result was much longer than the traditional method because there was a spike at one time for the response time of the proposed method. However, that does not mean the proposed method sent a response back with the worst time because the average response time of the proposed method was 0.28 ms, which was still within a reasonable value for real-time applications.
In testing the response time for 500 users who sent 50 prediction requests, the traditional method showed that the fastest response time was 0 ms. However, the highest response time was 11 ms with an average response time of 0.07 ms, indicating that the traditional method could still send a response back to the user quickly enough. With a slight difference between the lowest and highest times, the traditional method can be used for applications that depend on data transmission speed. The intended performance of this test against the traditional method provides insight into the fact that the MQTT broker has a good and efficient communication speed.
On the other hand, for the proposed method, the shortest response time was 0 ms. However, the highest response time was 261 ms with an average response time of 0.34 ms, indicating that the proposed method can provide excellent performance under some ideal conditions but, at certain moments, can also provide a slow response under certain conditions. Factors such as the number of messages being processed and network load can trigger these spikes. From both results, it can be seen that the architecture can still have excellent performance judging from the shortest response time, but the proposed method can have a slow performance at certain times with the highest response time value at 261 ms. There is a notable difference in standard deviation between the two methods; from the last two tests, it can be observed that the proposed method has a more significant standard deviation value than the traditional method. The result of a higher standard deviation on the proposed method can happen because moving data from MQTT to Kafka takes time.
From the tests that were carried out, it was found that there was a trade-off with the existing method. The traditional method provided faster results than the proposed method, as seen in the maximum value obtained; the traditional method was faster than the proposed method. In addition, the proposed method provided results with a more excellent average value than the traditional method and spiked at some moments. However, the standard deviation data state that there is a more profound difference between these results. The traditional method had a more significant value than the proposed method, such as in the third scenario, where the standard deviation of the traditional method was 5.71 ms. The proposed method was 0.28 ms, indicating that although the traditional method had a faster maximum value, it was not very stable for the time obtained in contrast to the proposed method, which, although the average value was relatively higher than the traditional method, provided a very stable value compared to the traditional method as can be seen in detail in
Table 2. The standard deviation results also show that the spikes obtained from the proposed method will be rare. Therefore, the proposed method is more suitable for environments requiring stability, but the traditional method is more suitable if you need speed.
3.7. Comparison with Existing Work
To explore the results that have been obtained more deeply, the authors compared them with several studies that have been carried out regarding real-time monitoring using Kafka by comparing some of our evaluations and the ones available in existing work. The detailed results can be seen in
Table 7.
The first piece of research discusses using Apache Kafka to implement a wireless and real-time image streaming system for traffic monitoring. This research tries to improve the performance of streaming images on the first two things, namely, the implementation of Software-Defined Wireless Mesh Network and Apache Kafka for data distribution. The evaluation data show that the performance of using Apache Kafka alone has the lowest latency at 1909 ms.
In the following research, event-driven cloud architecture was carried out using MQTT and Apache Kafka to determine efficient and cost-effective architecture. This research uses AWS as a cloud service and sets the availability zone to three zones to increase throughput. In the results obtained from the paper, the lowest latency was 250 ms with a throughput value of 8000 packets/s. The value of this research is relatively high. However, the research does not explain the data sent and the evaluation scenario.
The third paper discusses monitoring the condition of building structures. This research aims to find an architecture that can be monitored in real-time with low latency based on streaming data. This research uses Apache Kafka, Apache Flink, and Websocket to create its architecture. This research consists of three subsystems consisting of sensors that aim to collect, process, and analyze data using Apache Flink and store and display data using Websocket. Apache Kafka’s role is to serve as a bridge between subsystems. This research obtained the lowest latency value at 36.69 ms.
The last piece of research discusses Cloud Manufacturing, which emphasizes integrating distributed resources using the cloud and IoT in microservices. This research addresses scalability, performance, resource orchestration, and security challenges. This research uses Apache Kafka for fast and stable data ingestion, Apache Spark Streaming for fast data processing, and Rabbit MQ to maintain communication between services. This research results in obtaining the lowest latency at 5 ms and the highest throughput at 700 packets/s.
Based on the research that was conducted, the proposed method in this research, using MQTT and Kafka, can outperform existing methods, especially for the latency given in the proposed method, which is 0.9, a minimal value compared to existing work. Although the throughput can be defeated by one of the studies that can generate throughput at 8000 packets/s, there is no certainty about how to evaluate factors such as users who request at one time, and the availability zone in the cloud can also affect the results obtained.
5. Conclusions
In this research, comparing traditional inter-cluster communication methods and the proposed CVD disease monitoring methods provides several important points; we start from the test results of several scenarios.
In the response time results, both methods obtained the lowest value at 0 ms, which indicates that both methods can perform well in an adequate environment. As the number of requests increases, the proposed method experiences an increase in response time with a maximum value of response time of 261 ms in the third scenario; this result makes the average response time of the proposed method increase so that the response time of the proposed method becomes longer than the traditional method. However, looking at the standard deviation data, the traditional method has a much more unstable response time value; the proposed method has a standard deviation that tends to be stable, with a standard deviation of 0.28 ms, while the traditional method is at 4.14 ms. The same thing happens to the latency results, whereas the proposed method has a more excellent value on the average latency value. However, when looking at the standard deviation between the traditional and proposed methods, the latency value in the proposed method is 93% more stable than the traditional method as with the traditional method, standard deviation is 7.6 ms, and with the proposed method, standard deviation is 0.51 ms. This phenomenon can occur because the proposed method has an additional layer for data processing, so there may be time spikes when data processing occurs.
For the success of both methods in processing the data provided by the user, the proposed method has a better value than the traditional method. However, in the first two scenarios, the proposed method has a smaller error value than traditional as seen in
Table 6. This makes the proposed method not only stable in terms of data processing time but also means that it has better data processing accuracy than the traditional method. The satisfactory result of the proposed method lies in the ability of Apache Kafka to handle larger data volumes efficiently, making the combination of MQTT and Kafka provide a more stable architecture for real-time monitoring systems. However, this ability requires an environment with considerable resources, where there is an increase in RAM usage along with the number of users making requests. In the research results, the highest point of RAM usage for the proposed method is 25% greater than the traditional method, so this method is less suitable for environments that have limited resources. Therefore, the continuation of this research can be focused on optimizing the use of resources such as the use of data compression techniques. Some important points from the research that has been carried out are:
The proposed method achieves higher throughput compared to the traditional method, making it more efficient for handling large volumes of data;
The response time of the proposed method increases with more requests, reaching a maximum of 261 ms. However, the traditional method has higher standard deviation than the proposed method;
In terms of latency, the proposed method has higher average latency but is 93% more stable than the traditional method;
The success rate of data processing is higher in the proposed method, with a lower error rate in the first two scenarios;
Apache Kafka’s role in the proposed method improves data handling and system availability;
The proposed method requires more resources, with RAM usage increasing by 25% compared to the traditional method.
In the traditional and proposed methods for this research that aims to process data in real-time with the context of health monitoring, there is a significant trade-off of resource requirements, but cloud dependency that requires internet stability. The cloud offers scalability and ease of management but requires a stable network between the user and the architecture for data processing. Therefore, this research can open up other opportunities to reduce the significant latency due to internet stability in several ways proposed in
Section 5.
In addition to CVD monitoring, the proposed method can be applied to other fields requiring real-time communication, such as general patient monitoring, architecture for wearable devices, telemedicine or Industrial IoT purposes requiring real-time communication, and fast modeling. However, further testing should be conducted to replicate the capabilities of the proposed method in real situations, such as testing under unstable network conditions. In addition, research focusing on security enhancements could also be performed since this system stores sensitive patient data. Security will be an important aspect that needs to be developed.
With regard to this, this research has contributed to improving the efficiency of microservice communication for health monitoring systems and other fields. It opens up opportunities for further development in data source efficiency and data security.