Best practice for showing MQTT Data on a website

Let’s consider I have a fleet of 1000 cars. The cars have a device on board that sends data (speed, location, amount of fuel, etc.) to our HiveMQ Broker. The data is sent event-driven.

Each car owner has access to a web page where they can see their car’s information live. So if Tom accesses the website he will see his BMW’s information, if Jeff accesses the website he will see his Bentley’s information, etc.

To connect the website with the MQTT broker (it allows only connections on 8883 with valid certificates), I have thought the following:

  1. To have a MQTT client on the webserver and to subscribe this to all the topics - although I think this would generate a bottleneck.
  2. Using the library (NodeJs) send the data to the corresponding people.

Is this state of the art?
How to avoid the bottleneck in the client who subscribes to all the topics?

Any suggestions or ideas on how to make this better and more scalable, for example if in the future there are 100,000 cars?


a technically simpler solution would be to connect the client webpage directly to the broker via WebSocket. Since every client only subscribes to its own topics the bandwidth is low per client.

This setup obviously requires careful data security consideration to avoid leaking data to anybody else since the broker is accessible publicly. The webpage/user needs to authenticate itself with credentials. There are different options how to handle this described in the documentation.

I´m not sure if the certificate requirement you mention might be an issue in this setup. Scaling to 100k cars might become an issue. But first:
Do all users open their webpage while driving or on demand?
How much users will be actually connected to the broker?
How often is the data updated by the cars per second?

Depending on these answers it might be worth looking into a more complex cluster management and load balancing setup. But IMHO I would start as simple as possible and keep an eye on the server analytics.


Thanks for your answer. At the end I connected using WebSocket as you suggested.

1 Like

hi, i started using hive-mq cloud basic free plan (upto 100 connection)
i’m trying to connect with the broker using mqtt.js
but there is no port number mentioned in any documents for websocket connection.
so how did you connect with hivemq cloud cluster using websocket ?
what is the port number ? and whats your full url looks like ?

Hello Fida,

Welcome to the HiveMQ community forum. Glad to see you’re taking interest in MQTT and HiveMQ.

HiveMQ cloud does not support Websocket yet but this feature is on our roadmap.

The FAQ post will be updated as soon as the feature is released.

Kind Regards,