C # begin * () method vs threadpool for server

To create a scalable multi-user server in C #, which of these two types of servers is more efficient? You can see an example of an asynchronous server using the begin * methods (e.g. beginaccept, beginend) here , and the threadpool implementation here .

I know what threadpool is and how it works, so I pretty much understand how this implementation works. What about an asynchronous server? Does this spawn a thread for every send, receive, and connection event? How effective is it against threadpool?

By efficiency, I mean the overall balance of speed and memory usage.

change

I was asked to use begin () methods, but do they create overhead when they spawn a new thread to take care of a send, receive, or connection event? Or do they end up using some kind of internal threadpool? If not, is there a way to do this so that it uses threadpool or do I just need to collapse my own asynchronous socket server?

+5
source share
5 answers

If scalable, you mean a really large number of connections, you should also consider a number of other aspects not related to the thread pool.

1) .NET3.5, SocketAsyncEventArgs, BeginXXX/EndXXX. MSDN Magazine. -.

2) . [], -, , GC , , , OutOfMemoryExceptions . , , - , .

( , - LOH ) -, .

+2

TcpServer , - , threadpool, , , , .

, async , , , (, ), - , , , , . , , , .

+4

Jeffery Richter AsyncEnumerator. Wintellect PowerThreading Library. - , 9.

, , threadpool , . .

+1

, begin/end . , . , , , , . , ? , - , , .

+1

, , .

, :

  • /

,

  • ,
  • Hardware

Before moving on to choosing a design, first remove the basic requirements.

0
source

All Articles