I see the following tweet getting attention. It’s fundamentally incorrect. WebSockets are scalable.
There is nothing special about MQTT or any other binary protocol you can invent that make your application scale better. (Differences exists ofc, but not at high level).
There are two key drivers:
1. the cost of maintaining a persistent connection in your OSS and infra
2. the capability of your application to offer stateful guarantees while allowing clients to reconnect to multiple servers
MQTT semantics provide a fantastic base for this for the 2nd part. Most WebSocket-based applications fail spectacularly at this.
WebSocket is a *very costly* protocol, as it cost a relatively high amount of CPU time to decode the messages and encode them again, but you can make it scale very well if needed.
Websockets which a lot of people use while building realtime communication (such as chatapps) are not scalable for large userbase.
It can be good for small scale startups but large scale companies don't use it.
Most of the times, either companies write their own custom protocols or use pubsub models like MQTT.
In websockets, open connections are all handled by application servers. This requires alot of resources. Horizontal scaling can't be done beyond a point since u can't add infinite/a lot of servers becz its expensive.
Since browsers only have websocket for two way communication, most companies build their protocol by taking websocket as transport layer. And don't use it as application layer with socketIo.