3 ms·
Looks very nice for quick prototype kind of things in any language or to make existing tools quickly available to a small circle of users! for larger-scale usa
by detaro 12y ago
Looks very nice for quick prototype kind of things in any language or to make existing tools quickly available to a small circle of users!
for larger-scale usage the overhead probably is to big.
- hippich 12y agoDepending on the job. If your job involve long lasting connections, overhead of setting up websocket connection and spawning new process wouldn't matter. But this is clearly will not cut for typical HTTP static stuff. So if your server side keeps connection for a long period of time (think IRC server, or netcat?) - this might be good.
- phamilton 12y agoThe overhead isn't the setup. It's the memory footprint of a process. A minimal process (just sleeping) will use ~128KB. One process per connection means a server will need well over 1GB memory per 8000 connected users. A python process just sleeping will be almost 3MB, which means you get 333 connections per GB. Compare this with an efficient green threads implementation. In Erlang you can have 100k sleeping "processes" in just 200MB of memory.
- hippich 12y agoYes, there is memory overhead, just like there is programmers overhead to create daemon doing what you need, instead of just piping existing tool's stdio into websocket. I guess each tool should be used for tasks it is good at.
- joewalnes 12y agoOP here. The overhead is really dependent on your process overhead. I typically use it for Python/Ruby/C apps which are relatively lightweight compared to something JVM based. The runtime profile of WebSockets tends to be different to typical HTTP requests too. With typical HTTP you're often optimizing for 1000s of short requests per second, whereas with WebSockets the requests are much longer lived.
- jeremiep 12y agoThe JVM is optimized for long-running processes as it takes time for the JIT to kick in. Other than the memory footprint your code gets quite a performance boost; I'm always surprised how much of a difference it makes before and after. You wouldn't want to boot a JVM process per connection but rather implement the listening socket yourself and dispatch connections within that same process with all of the required services already initialized. A WebSocket server is no different.