Comparative Performance Analysis Between the MQTT and WebSocket Protocols - Muhammad Faishal Tsaqief; Joko Sutopo (Komunitas Dosen Indonesia, 2025)
In the era of smart monitoring and real-time 3D visualization, communication delay remains a critical challenge for resource-constrained IoT devices. This study aims to determine which protocol MQTT or WebSocket delivers superior performance for real-time sensor data streaming in such latency-sensitive contexts. A controlled experimental setup was implemented using an ESP32-S3 microcontroller and an MPU-6050 inertial sensor, streaming 1,000 data samples per protocol to a Python-based server hosting a local Mosquitto MQTT broker. The evaluated performance metrics included mean latency, jitter (standard deviation of latency), and packet loss rate. Results indicate that under the tested LAN environment with a local broker, MQTT (using QoS level 0) significantly outperformed WebSocket. MQTT demonstrated substantially lower mean latency (11.040 ms vs. 41.544 ms), markedly reduced jitter (0.201 ms vs. 18.824 ms), and a superior packet loss rate (0.501% vs. 0.937%), showcasing exceptional stability and timing consistency for real-time data delivery. In contrast, WebSocket exhibited significantly higher latency and jitter, which would be detrimental to motion-sensitive applications. These findings challenge the common assumption favoring WebSocket for low-latency tasks and suggest that MQTT offers a more robust and suitable communication protocol for real-time 3D visualization on resource-constrained IoT devices within local network conditions. The superior performance of MQTT in this context provides a strong rationale for its adoption in edge computing-based visualization systems, where timing consistency is paramount.