I want to develop chat application and using MQTT and Web socket for live notification, active status at client (mostly web browser). I am wondering that how can I make communication between clients in best possible way to reduce load at MQTT and for smooth communication.
For example, If client A sends a message to client B then options are
1) Make a separate topic for communication between client A and client B
It doesn't look a good idea as if number of clients in application will increase then number of topics between each user will highly increase which will put a load on MQTT broker.
2) Send message on basis unique client Id
MQTT doesn't allows to publish message on basis of client Id
3) Make a single topic for communication among all the clients (all clients will subscribe the topic and relevant client will perform its operation if the message is related to it)
Lots of client will recieve unwanted messages and as the number of clients will grow then it will increase the problem.
In case if all the clients subscribe to a single topic, Is it possible to filter out the client who should receive the message
What can be the other solutions to make a smooth chat application and what solution does other applications use such as slack, telegram, whatsapp etc. Do they also use MQTT and if not then how do they achieve this.
Thanks in Advance