Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
DevRage51027y@Artemix ill try that tomorrow , i dont want to add more load to the database just for the chat
-
I've actually built a chat system using web sockets (SignalR, .NET based)
It works quite well :)
The one thing I will point out, is images. Sending these as base64 strings do no work. The data is simply too large
I'm not sure if you'll encounter similar with paragraphs of text -
Froot75547yHOLY FUCKING SHIT why is this even a question? 😆
Of course you use websocket. Long polling makes 0 sense for anything if you can use websockets. Long polling is basically a websocket polyfill. It's like asking If I should use the spare wheel on my car or put the regular one on 😆
Also, use socket.io, it will sort the whole transport layer out for you with relevant fallbacks when needed.
Edit: oh your using Wordpress... smh -
@Froot I used polling the other day 🙈
It is for an auto save as you type form though. So that's my excuse 😉 -
vertti4537yFor any serious applications use Erlang/Elixir. Perfect for chat apps. Obviously via websocket.
Don't even touch socket.io with a long stick if you're building anything than just a prototype.
Database depends on a few things, like if you need it persistent or in-memory. -
vertti4537y@lewdogg I beg to differ.. It's very hard to build anything scalable on node for chat. It'll also be error prone and have a high memory footprint. Scaling will be particularly tough.
There are better and more productive alternatives out there for chat, but if you already know node perhaps it's the easiest to put together something really simple with it. -
lewdogg9957y@vertti php websockets are easy enough too. I have done both. And both seem like they have their merits.
But hey, anytime you get a chance to dive into some node and learn up, you gotta take it.
I have been doing some interesting projects on my raspberry pi’s that use websockets and have yet to push it to the breaking point, but who knows, maybe they will break soon. -
vertti4537y@linuxxx and @lewdogg we built node as well as Erlang backends for chat. Tested both using tsung stress tests. Launched a few hundred thousand simultaneous connections to each, sending and receiving messages on group chat channels.
Node (socket.io) starts choking awfully early. Latency also quite a lot higher than on Erlang. Will start losing packets and CPU and RAM usage goes through the roof.
Erlang handles a massive number of simultaneous connections and traffic over them rather easily. Node fails miserably in comparison. Scaling just to use many cores in a system is tough for node. Something that's well designed out of the box in Erlang VM.
If you really need to use node/socket.io for chat, at least change the websocket engine in socket.io to uws. Then it performs a bit better -
Froot75547y@vertti @linuxxx I would recommend socket.io + node.js too. Built many applications on that and haven't had any problems yet. Also how is scaling difficult? I does seem to me that only thing you have to keep in mind is not to share data between connections over memory and you're fine, could be wrong tho.
-
@Froot I've tested applications on lowend servers running through socket.io and thousands of connections sending data every second gets handled just fine!
-
Froot75547y@linuxxx Cool. I'm always confused when people say that node is slow or it uses alot of memory or CPU because when I've used it it seems one of the leanest options out there.
-
vertti4537y@Froot when you start scaling in node you'll need to have a sort of in-memory database. Like redis. In Erlang the virtual machine (called BEAM) handles this all straight out of the box without any need for such a thing. You can even connect different machines running Erlang to each other in just 1 command, and you're all set.
I think if you run your own tests you'll see that Erlang well outperforms node in this type of application. I've never seen node beat Erlang in scalability or performance in a chat application. Actually I don't think anything can beat Erlang in such an application.
If you only intend to have a few thousand simultaneous users it hardly matters. You can do it with almost any language/runtime. But once you go to hundreds of thousands and more it makes all the difference in the world.
There is a reason whatsapp, RabbitMQ, Discord etc. use Erlang/Elixir instead of node. Achieving those simultaneous user counts would be borderline impossible on node. -
@vortexman100 Usually where Javascript will make a request to the server every X seconds
Imagine an XMLHttpRequest in a setInterval basically
Should i make a chat system using polling or websocket?
undefined