Re: Problem with BackLog (TCP Queue)..
- From: "Chizl" <Chizl@xxxxxxxxxxxxxx>
- Date: Mon, 7 Jan 2008 18:47:07 -0600
First of all thanks for taking the time to respond.. I have some comments
below.
"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message
news:op.t4kn99s48jd0ej@xxxxxxxxxxxxxxxxxxxxxxx
My recollection is that the operation system has its own maximum backlog
value. Trying to set the backlog above this value will result in either
no effect, or setting to the maximum value. In neither case will you get
the backlog you're asking for.
Doesn't that defeat the purpose of the call? I assume this is like
Affinity.. The OS has one setting, but you can override that with an API
for a specific application. The API doens't change the settings permanent,
but it does for the life of the application and that application only.
One suggestion: in the code you posted, rather than having a thread sit
and loop calling BeginAcceptSocket() over and over, just have the
EndAcceptSocket() callback call it (and do so right away). The way the
code is written now, you are guaranteed a thread switch between accepting
one socket and being ready to accept another, and then of course another
thread switch to accept the next one again. This is going to
unnecessarily inhibit your throughput, artificially reducing the number of
simultaneous connection requests you can process.
I'll look deeper into this, but I got this info from MS.
http://msdn2.microsoft.com/en-us/library/system.net.sockets.tcplistener.beginacceptsocket.aspx
You have other performance-hindering design choices there as well:
* your accept callback really should be doing very little. If you
have some heavyweight processing you want to do when accepting a client,
you should handle that elsewhere if handling a large number of
simultaneous connections is a priority for you. Otherwise, you get stuck
with a thread that's doing something other than accepting connections.
I'm assuming you mean my MyWebServer.AddConnection() call. That's doing
nothing but checking current connections < max connection, then incriment a
counter.
* You should not be creating a new thread for each connection. Use
the async i/o methods for the Socket class instead (e.g. BeginReceive).
Using a thread for each connection you will unnecessarily limit the
maximum number of connections you can handle -- the number of threads any
given process can create is much lower than the number of sockets a
process could theoretically handle -- and at the same hurt performance
because of the constant thread context switches that will be required to
deal with multiple active connections.
The thread I'm creating is after I've released the callback. In VC++ I've
tested a spawn of over 2000 threads, your saying in C# that isn't possible?
Based on the examples I've seen with using BeginReceive() it's holding the
receive open longer than I currently am. But I'll look deeper and see if I
can find some better examples.
.
- Follow-Ups:
- Re: Problem with BackLog (TCP Queue)..
- From: Peter Duniho
- Re: Problem with BackLog (TCP Queue)..
- From: Chizl
- Re: Problem with BackLog (TCP Queue)..
- References:
- Problem with BackLog (TCP Queue)..
- From: Chizl
- Re: Problem with BackLog (TCP Queue)..
- From: Peter Duniho
- Problem with BackLog (TCP Queue)..
- Prev by Date: Re: Net Remoting and Performace
- Next by Date: Re: Reuse Method
- Previous by thread: Re: Problem with BackLog (TCP Queue)..
- Next by thread: Re: Problem with BackLog (TCP Queue)..
- Index(es):
Relevant Pages
|
Loading