Marcus Werlinder

Comparing MQTT and WebSocket scalability, using Amazon Web Services

This study compares scalability of two popular communication protocols, MQTT and WebSocket.
The scalability comparison of the protocols was done using a publish-subscribe pattern.
EMQX was used to run the MQTT message broker, and Socket.IO was used for the WebSocket message broker.
Five metrics were recorded; memory usage, network usage, CPU utilization, Round Trip Time (RTT) and message loss.
The brokers were put in two different scenarios. The first being many publishers and few subscribers, and the second being
many subscribers with few publishers. AWS EC2 was used to host the brokers, as well as the publishers and subscribers.

The findings of this study were that WebSocket is best suited for memory usage and CPU utilization.
MQTT is much better suited when it comes to network usage. MQTT had a slightly better RTT in the first scenario
and half of WebSocket's RTT in the second scenario. Both communication protocols perform similar for message
loss, with WebSocket having zero dropped message, while MQTT had a drop rate of only 0.01%.