Hacker News new | ask | show | jobs
by latch 1211 days ago
Honestly, what matters is (a) what you're going to be doing with those connections and (b) your hardware.

As a generalization (again, really depends what you're going to be doing), I'd expect people to get a lot further with a Go or Java based implementations. Specifically, if those connections are interacting with each other in any meaningful way, I think shared data is still too useful to pass up.

I've written a websocket server implementation in Zig(1) and Elixir(2)

(1) https://github.com/karlseguin/websocket.zig (2) https://github.com/karlseguin/exws

1 comments

> Specifically, if those connections are interacting with each other in any meaningful way, I think shared data is still too useful to pass up.

What does this mean? What are some scenarios where connections interact with each other? I work with dotnet. To me, every request is standalone and doesn’t need to know any other request exists. At the most, I can see doing some kind of caching where if someone does a GET /person/12345 and someone else does the same, I maybe able to do some caching. However, I don’t think this is what you meant by shared data.

Did you mean like if someone does a PUT /person/12345/email hikingfan@gmail.com instead of the next get request reaching to the database, you keep it in the application memory and just use it?

Or am I completely missing the point and you’re talking about near real-time stuff like calls and screen sharing?

This is in the context of a websocket (which is what the original story is about). Presumably, websocket is being used because HTTP isn't enough, namely, you want to receive pushes from the server. This _often_ comes in the form of data that multiple connections are interested in: game state, chat, collaborative editing. At scale, this data, or a copy of it, often stays in memory. E.g. a chat system might keep a list of room + brief chat history + user list in memory. This memory is being mutated by concurrent connections.
Many languages (e.g, NodeJS) won’t even let you share code. So you can’t really do stuff like have hundreds of threads without being very careful with the size of your application code, because each thread will get a copy.
If you need to send messages to other channels, or use shared caches, or have shared state like a game server.