-

@ mikedilger
2024-04-10 04:56:06
Yes I count how many sessions are open, I could stop accepting requests when that number gets too high. In my deployment scenario it only gets to 70 tops, but there are only 3 of us on there.
I'm using asynchronous rust. It doesn't use one-thread-per-socket. Instead, there is one-thread-per-core, and whenever a thread hits a wait point (waiting for socket I/O or a timer or anything else) the task gets shelved, and as soon as an event happens related to any of the shelved tasks, an idle thread goes and handles it up to the next await point. All cores can be fully busy if I/O becomes ready fast enough, but most of the time all cores are just waiting for I/O.
TCP/IP ports are 16-bits, so the maximum port is 65535. Ports below 1024 are reserved for system services and aren't randomly allocated. Each websocket connection uses one of these 16-bit ports among these 64511 available ports. You can't have more network connections than that AFAIK. So we can't serve 1 million clients simultaneously. I might be wildly wrong about this.