Re: Problem with BackLog (TCP Queue)..
- From: "Chizl" <Chizl@xxxxxxxxxxxxxx>
- Date: Mon, 7 Jan 2008 19:09:00 -0600
FYI, I changed the registry settings.. I have zero socket errors now..
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"TcpNumConnections"=dword:00fffffe
"MaxFreeTcbs"=dword:000007d0
"MaxHashTableSize"=dword:00000200
"TcpTimedWaitDelay"=dword:000000f0
=============================
Stats..
=============================
Number of hits: 13094
Requests per Second: 109.11
Socket Statistics
--------------------------------------------------------------------------------
Socket Connects: 13099
Total Bytes Sent (in KB): 5966.29
Bytes Sent Rate (in KB/s): 49.72
Total Bytes Recv (in KB): 97789.26
Bytes Recv Rate (in KB/s): 814.86
Socket Errors
--------------------------------------------------------------------------------
Connect: 0
Send: 0
Recv: 0
Timeouts: 0
RDS Results
--------------------------------------------------------------------------------
Successful Queries: 0
Script Settings
=============================
Server: localhost
Number of threads: 200
Test length: 00:02:00
"Chizl" <Chizl@xxxxxxxxxxxxxx> wrote in message
news:ex7jIAZUIHA.5288@xxxxxxxxxxxxxxxxxxxxxxx
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: Willy Denoyette [MVP]
- Re: Problem with BackLog (TCP Queue)..
- From: Peter Duniho
- Re: Problem with BackLog (TCP Queue)..
- References:
- Problem with BackLog (TCP Queue)..
- From: Chizl
- Re: Problem with BackLog (TCP Queue)..
- From: Peter Duniho
- Re: Problem with BackLog (TCP Queue)..
- From: Chizl
- Problem with BackLog (TCP Queue)..
- Prev by Date: Re: P/Invoke explanation
- Next by Date: Re: Start 'invisible' process
- Previous by thread: Re: Problem with BackLog (TCP Queue)..
- Next by thread: Re: Problem with BackLog (TCP Queue)..
- Index(es):
Relevant Pages
|