runaway thread count and asynchronous sockets

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Matthew Groch (mgroch_at_brisksystems.com)
Date: 10/01/04


Date: 1 Oct 2004 08:58:23 -0700

Hi all,

I've got a server that handles a relatively high number of concurrent
transactions (on the magnitude of 1000's per second). Client
applications establish socket connections with the server. Data is
sent and received over these connections using the asynchronous model.

The server is currently in beta testing. Sporadically over the course
of the day, I'll observe the thread count on the process (via perfmon)
start climbing. (Let's say that on average, a 'normal' thread count is
around 80). But when it climbs, well.. Today, for example, I saw it
peak at around 355 threads.

Now, I don't explicitly spawn these threads in my code. I'm assuming
they're being spawned by the CLR to handle the high volume of async
socket sends. The count stays high for some (arbitrary?) period of
time and then, automagically, comes back down to normal levels again.
When the thread count is high, the system is obviously taxed and
performance goes down. I've written code specifically so that I keep a
flag associated with a socket session such that a session will not
initiate an async send if one is currently in progress, if that's
worth mentioning at all.

I'm hoping to hear from _anyone_ that might have encountered a similar
situation!! I'm not exactly sure what to do at this point. I'd love
any help and am particularly looking for responses like "Hey, have you
thought about this?" or "Hmm, maybe you're misunderstanding some
fundamental concept in async socket comm", or best, "Yeah, that sounds
similar to something we ran into last year; here's the strategy we
used to get around it.."

Thanks in advance-



Relevant Pages

  • Re: How to terminate a socket in CLOSE_WAIT state
    ... FTP Server fixed for certain FTP clients who use both passive ... This was causing a PASSIVE opened socket to be left ... but instead expect the "half close" from the receiver. ... this sends a TCP/IP FIN packet to the ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Socket switch delay
    ... both at the client and at the server (and why ... would you set the send buffer size to zero on a non-overlapped ... One glaring error is your client does ... So when you use a single socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Applet Hangs when submitting data to servlet
    ... to put a time limit on my socket connections and socket reads. ... public void setTimeoutthrows UnknownHostException, ... on our web server. ... private JButton theSubmitButton_, theClearButton_; ...
    (comp.lang.java.programmer)
  • Re: Problem with writing fast UDP server
    ... UDP packets per second. ... socket and threads. ... I wrote a simple case test: client and server. ... The maximum theoretical limit is 14,880 frames per ...
    (comp.lang.python)
  • Re: Socket Exception
    ... In this case the server most likely rejected your ... connection. ... Each command is a new socket connection that is opened and closed ... /// Required designer variable. ...
    (microsoft.public.win32.programmer.networks)