# A Reliable Publish-Subscribe Mechanism for Internet of Things-Enabled Smart Greenhouses
## 4 Performance Evaluation
### Evaluation Model  
To evaluate the efficacy of the MQTT broker regarding message size and message quantity, it is necessary to use the \(M/M/1\) queuing model as proposed by [45] in their study on performance analysis. In the standard \(M/M/1\) model:  
* The first \"\(M\)\" denotes that the arrival process follows a Poisson distribution, indicating that the time intervals between the arrival of messages are exponentially distributed. * The second \"\(M\)\" signifies that the service process follows an exponential distribution, indicating that the time required for the broker to process a message is exponentially distributed. * The numeral \"1\" in the system signifies the existence of a solitary server, namely the MQTT broker, according to [46]. In our analysis, we adapt the \(M/M/1\) model to reflect the characteristics of MQTT protocol communication. The critical variables for our modified model are the message arrival rate (\(\lambda\)) and the service rate (\(\mu\)), along with specific MQTT-related factors such as message size and QoS levels. _Modifications to the M/M/1 Model:_  
* Message Arrival Rate (\(\lambda^{*}\)): This represents the rate at which messages arrive at the MQTT broker. This rate varies depending on the QoS levels and the payload size. For different brokers and QoS levels, \(\lambda^{*}\) will differ. * Message Size (\(\pi^{*}\)): Unlike the standard \(M/M/1\) model, which may not account for varying message sizes, our modified model incorporates the fixed size of messages (\(\pi^{*}\)) for both the original and proposed MQTT brokers, measured in bytes. * Service Rate (\(\mu\)): The broker's capacity to handle incoming messages determines the service rate. It reflects the processing capabilities of different MQTT brokers under various configurations. _Formalization:_ Let \(\lambda\) be the arrival rate of messages, and let \(\mu\) be the service rate of the MQTT broker. Assuming that the arrival rate follows a Poisson distribution and the service time follows an exponential distribution, the system can be modeled as an \(M/M/1\) queue, denoted by this abbreviation \(q_{M/M/1}=(\lambda,\,\mu)\). Furthermore, the expected number of messages and the expected time a message spends in the system are computed employing \((L)\) and \((W)\) as shown in Equations (1)-(3). \[L=\lambda/(\mu-\lambda) \tag{1}\]  
\[W=1/(\mu-\lambda) \tag{2}\]  
\[L=\lambda W \tag{3}\]  
Importantly, as demonstrated in the assumption, we assume two variables in both the original and proposed MQTT protocol broker frameworks: the arrival message rate in three QoS levels, and the message size. According to Formulas (1)-(3), we provide our proposed Formula (4) for our architecture to obtain the expected number of messages through the \(M/M/1\) model on the proposed MQTT broker architecture. \[L^{*}=\lambda^{*}/\pi^{*} \tag{4}\]  
* \(L^{*}\) represents the anticipated number of messages that are published in each topic. * \(\lambda^{*}\) refers to the rate at which messages arrive, measured in messages per second. * \(\pi^{*}\) represents the fixed size of messages for both the original and proposed MQTT brokers, measured in bytes. By applying the modified \(M/M/1\) model mentioned to the proposed categorized topics structure in MQTT, we can analyze the performance of the system in terms of the message size, the number of messages, and the message transaction process [45]. This analysis can help us optimize the performance of the MQTT broker and ensure that the system can handle the expected message load through the following strategies:  
* Optimized Topic Categorization: As detailed in Section 3.2, we propose a standardized message structure with unique topics for each data point and event within the greenhouse environment. This approach reduces topic overlap and ensures efficient routing and processing of messages.