# High Performance IoT Cloud Computing Framework Using Pub/Sub Techniques
## 3 Computing Platform Using MQTT and Kafka
### Data Processing Based on Publish and Subscribe Architecture  
The MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging, such as with low-power sensors or mobile devices, such as phones, embedded computers, or microcontrollers [14]. Based on the publish/subscribe model, an MQTT broker remembers multiple components subscribed to a particular topic and forwards the data as it is received. The IoT cloud platform makes use of the MQTT and Kafka protocols. It plays a key role in reducing the burden on IoT devices. This is because the devices only serve the corresponding platform that is physically close to the IoT. Kafka clusters communicate using the Kafka protocol. Like MQTT, it uses a publish/subscribe model and serves to stream large amounts of continuous data from sensors. In this research, we provide a web-based dashboard platform for monitoring data configured using \"ThingsBoard\" [15; 16]. The ThingsBoard is an open-source IoT dashboard [17] platform designed to store data in MongoDB [18; 19].  
After we collect sensor data generated from the sensor module located in AREA 1, the data are published to subscribers through the IoT cloud platform, as shown in Figure 4. The data are classified as an MQTT component by topic (classified by temperature, sunlight, rainfall, etc.).  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Name** & **Address** & **Read Access** \\ \hline Melexis reserved & 0x00 & Yes \\ \hline \(\ldots\) & \(\ldots\) & \(\ldots\) \\ \hline Melexis reserved & 0x03 & Yes \\ \hline Raw data IR channel 1 & 0x04 & \\ \hline Raw data IR channel 2 & 0x05 & \\ \hline T\({}_{A}\) & 0x06 & Yes \\ \hline T\({}_{\text{OBJ1}}\) & 0x07 & Yes \\ \hline T\({}_{\text{OBJ2}}\) & 0x08 & Yes \\ \hline Melexis reserved & 0x09 & Yes \\ \hline \(\ldots\) & \(\ldots\) & \(\ldots\) \\ \hline Melexis reserved & 0x1f & Yes \\ \hline \hline \end{tabular}
\end{table}
Table 1: Device configurations for input and output.  
Figure 4: Data publication architecture.  
Figure 5 shows that TOPIC-partitioned data is transmitted to the KAFKA cluster server and replicated to each broker in the cluster (each partition of the server). Every partition has one server that acts as the leader for all read/write operations within the server, and the other server acts as a follower of this leader. If a leader goes down or fails, by default, one of the followers on the other server is chosen as the new leader. Producers can generate specific messages going to selected partitions within a topic. Consumers can consume published messages based on topics. Messages are delivered to consumer instances within the subscribing consumer group.  
In Figure 6, the TOPIC-partitioned data is transmitted to the server (KAFKA Cluster) and replicated to each broker in the cluster (each partition of the server). Afterward, at the request of the consumer group, each broker in the KAFKA cluster designed a system capable of distributing data and transmitting large amounts of data.  
Data is increasingly produced at the level of the network. Therefore, it would be more efficient to also process the data at the level of the network. The IoT cloud platform eliminates bottlenecks and potential points of failure and enables rapid recovery from failures. The server in the IoT cloud performs functions for analysis and visualization of the collected time series data. In this way, the load on the server is reduced by dividing the roles according to the characteristics. It makes the server perform reliably in operation. For this reason, our platform aimed to reduce response time or latency by caching content [11]. The IoT cloud platform can be used wherever computing is used, such as location-based, Internet of Things (IoT), data caching, big data, and sensor monitoring activity spaces, mobile cloud, and others.  
Figure 5: MQTT communication pattern.  
Figure 6: Method of large data streaming in KAFKA.