DEV Community

Discussion on: How do you scale a nodejs real-time API to concurrently serve a million users?

Collapse
 
sandeepkamboj12 profile image
Sandeep kamboj • Edited

XMPP server is best solution for chat. Do not use node.js as chat data streaming.

Collapse
 
david_j_eddy profile image
David J Eddy

Could you provide some details / data on your statement. Why would you choose XMPP over a NodeJS app? Do you have any personal experience / empirical evidence the poster could use for references?

Collapse
 
sandeepkamboj12 profile image
Sandeep kamboj • Edited

Yes. 8 Android app built by me use XMPP (Openfire).

I previously use Node.js but there are many limitations in node.js

1) You need to built all things from scratch but in openfire XMPP server each and every thing that i want to use is already prebuild.

2) Node.js is good for broadcasting messages. But for one-to-one messaging. It is disastrous. On the other hand Openfire provides both of these.

3) Main problem with node.js is offline messaging.

Example. When User_A send message to User_B and User_B is offline at the time of messaging. Then message lost. To solve this problem you need to code all thing for this from scratch in node.js. But in openfire you don't need to worry.

4) You need to track all users sockets. But in openfire there is no such problem.
5) You don't detect which user is online or not in node.js. You need to program it that node.js ping for every 'X' seconds to users to track their availability. But In openfire you don't need to worry.

There are many other points.

In other words You just need to install XMPP server like openfire. And Go for your project. you don't create all thing from scratch like in node.js

I have one question. Why google,facebook,whatsapp use XMPP server for instant messaging and push notification. Why they don't even try to use Node.js

Node.JS real time API is just for fun.

I use Node.js previously But I face many problem . My client complaint that they don't receive messages. Buy when i heard of XMPP server. i used that in all my apps for push notifications and for chat.

Thread Thread
 
david_j_eddy profile image
David J Eddy

Thank you for the details. That is some very helpful information. I sure @presto412 has a better idea of the route to take now.

Thread Thread
 
presto412 profile image
Priyansh Jain

cubettech.com/blog/xmpp-chat-using...

How would you rate this? I'd like to keep my codebase consistent

Thread Thread
 
presto412 profile image
Priyansh Jain

Hey I would like to discuss this a lot further, could you follow me back or send me a mail at priyansh.jain0246@gmail.com ?

Thread Thread
 
david_j_eddy profile image
David J Eddy

I have followed you here on dev.to :).

Thread Thread
 
sandeepkamboj12 profile image
Sandeep kamboj

Mr. Priyansh Jain. That is node.js xmpp client not XMPP server.

Thread Thread
 
sandeepkamboj12 profile image
Sandeep kamboj

I think you don't read comment section in first block of code.

first : we need an xmpp chat server

second : establish connection to the chat server

Thread Thread
 
presto412 profile image
Priyansh Jain

Oh darn, didn't realise it.

Thread Thread
 
kaydacode profile image
Kim Arnett 

Love all the knowledge sharing in this thread. Just a friendly reminder everyone’s here to learn from each other’s experiences. 👍🏻

Collapse
 
mradigital profile image
mradigital

Hi Sandeep, are you available for some on going development work? If you are please contact me on glen.alexis@mradigital.com to discuss.

Thanks

Collapse
 
abhi12299 profile image
Abhishek Mehandiratta

Hey! A little late to the discussion, but I have a question. What if my application has custom chat requirements, such as only some users being able to message other users. For this we do need some sort of proxy/server in between the client and the XMPP server. How exactly should this case be handled where requirement is based on data stored outside of XMPP? A little overview/nudge in the right direction would be highly appreciated.
Thanks!