Asynchronous Streaming TCP Server

I want to create a high-performance server in C #, which can take about ~ 10 thousand clients. Now I started writing TcpServer with C #, and for each client connection I open a new thread. I also use a single thread to receive connections. So far so good, works great.

The server needs to deserialize the incoming AMF objects, execute some logic (for example, keep the playerโ€™s position) and send some object back (serialize the objects). I am not worried about serializing / deserializing the atm part.

My main problem is that I will have many threads with 10k clients, and I read somewhere that the OS can only contain a few hunderd threads.

Are there sources / articles for writing a decent asynchronous streaming server? Are there other options or will 10k streams work? I looked on google, but I could not find much information about design patterns or ways that explain this clearly.

+3
source share
4 answers

You will have a number of problems.

  • You cannot deploy 10,000 threads for several reasons. This will cause the kernel scheduler to crash. If you use 32-bit then the default address space of the stack is 1 MB, which means that 10k streams will reserve about 10 GB of address space. It will not succeed.

  • . O (N) . 10k .

  • IO Completion Ports. , . , , - IO. , P/Invoke Managed ++. .

+4

- ( , @Marcelo).

.NET, . . , .

+3

. , , 10 000 ; .

# (, ). google .

+1

-. threadpool -.

/ - . - , . , - / , , - .

+1

Source: https://habr.com/ru/post/1739213/


All Articles