Am 22.10.2013 14:07, schrieb James Pike:

Am 22.10.2013 01:39, schrieb Shammah Chancellor:

You need to send a message to the other thread to pass along. I am
doing something similar:

https://github.com/schancel/gameserver

Okay cool I modified my code to use this system now, although performance becomes terrible after about 5,000 busy WebSocket connections.

I guess because each Task spawns a real thread and I start getting a lot of context switching. I think to handle thousands of web sockets I'd need to delegate all the web socket writes to a single thread that uses async IO via a system of callbacks rather than fibres for synchronisation so that all writes can occur without blocking each other. Unless anybody can think of a better way...

It's not a thread per task, but a fiber per task (and fibers are
reused). Context switches of fibers are very fast and shouldn't be the
cause of the bad performance. If you can upload a benchmark/testcase
somewhere, I'd like to take a look at what takes so long.