I am thinking about creating an online "realtime" chat, between the client/browser and a webserver.
I am contemplating between using Websockets where 1 user writes to the server via their websocket and I send push out the message any other users and their sockets, versus having each browser do an ajax request every 0.5 and ask for any new messages.
For fun, let's say its a chat for 100,000 online users.
Both seems feasible from a business point of view. Both solutions will guarantee the messages will come in the same order and regarding the 0.5 seconds ajax request will give users a "real time feeling" enough.
Obviously, a Websocket solution should have "better bandwidth performance", as you only send the payload, compared to a full HTTP(S) ajax request every 0.5 seconds. However, the ajax request solution is more straight forward, plus you can put load balancing on these requests - which you cannot do with websocket. You can't break a socket during its connection, if the server starts to get overloaded. However.. is it really good asking a browser to perform an ajax request every 0.5 seconds.. maybe thats just insane for the end users(?).
So there is obviously pros and cons with both solutions.
In 2017, is there a clear winner regarding websocket vs ajax requests every 0.5 seconds out of a (server) performance point of view? Or is both solutions feasible if you just scale by adding new web servers.
Or any other feedback or insights would be appreciated!
Aucun commentaire:
Enregistrer un commentaire