Ben's blog

ramblings from cyberspace

Today I've continued on experimenting with this WS2HTTP idea and first started building the backend with Rust/Tokio...

Gotta say, I really didn't like it, it just felt so overly complicated. I suppose that's the price one has to pay for efficiency, but this was quite suprising since otherwise Rust is pretty nice to work in. Maybe I'll just have to try again some other time and things will end up making sense once one understands the basic ideas underlying these abstractions.

But since I'm still in the phase where I don't quite know how things will end up looking in the end I've decided to scratch the Rust backend and instead build the first prototype in Node.js, since I'm already quite familiar with how to build WebSocket/HTTP servers there, and once things stabilize and the design is done then I can take another look at implementing the same program in Rust. This also sounds like a great way to compare the performance of Node.js vs Rust/Tokio, since right now I just have a gut feeling that the Rust one will probably end up being faster/more efficient, but so far that is just an assumption on my part. Wouldn't be the first time that I'm suprised by how great modern JS runtimes are at optimizing code, and libuv has probably had a lot of effort put into it to make it as fast/efficient as possible. Although I suppose the single-threaded nature might become a bottleneck, but who knows, modern CPU's are super fast these days and since WS2HTTP is probably spending most of its time waiting for I/O it might end up not being an issue at all.

Now that I'm thinking about it, doing another implementation in go/erlang afterwards would be really interesting, and a great way to learn these languages. But first I'll have to get the base design with the Node.js version right, build a couple of example applications to test whether things actually work and then develop some benchmarks to see how much performance can be expected from this Architecture. For it to be a success to me it needs to support at least 1k msg/s and at least 10k open connections on a 5$ VPS, since that's pretty much the absolute upper bound from what I'm expecting for my tiny projects, I mean if there are more than 10k people using this App simultaneous I'll probably have to rewrite things to be more efficient anyways.

Alright, that's it, if you're interested, then you can see the current state over on GitHub