473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Async Socket: Rising Thread Count

Hi all -

We have been developing a complex TCP socket communication
app that is responsible for keeping numerous connections
open to clients on routable IPs. The app receives request
on a non-routable listener socket that marshals
communications between the non-routable netowrk and the
clients out on the routable network.

The app runs as a .NET service in Win2K Server. Async
sockets are being used, with BeginSend(), BeginReceive(),
EndSend(), EndReceive(), etc. Please correct me if I'm
wrong, but our understanding is that these async events
execute on a thread provided by a thread pool created by
the OS.

Operationally, the app is doing exactly what it designed
to do, BUT, the total thread count for the application
gradually rises over time (as displayed by Task Manager).
It starts out at about 18 threads, but after 24 hours it's
up to over 60 threads, and it keeps rising from there.

As expected with an async app, the number of threads does
not have a direct relationship to the number of open
connections. However, it is the marshalling of numerous
TCP messages that seems to make the thread count rise.
The marshalling of messages is when those asynch events
fire, and so I assume that the OS is creating additional
threads from the pool when they are not neccesary for the
operation of the app.

I ALSO assume that we have a bug somewhere. What I am
looking for are likely causes of the OS continuing to
assign additional threads from the pool to my process -
for example, what types of cleanup failures would cause
this? What if EndSend() did not get called properly? The
app is huge, so I would like to narrow it down to the most
likely culprit(s) so we can track this down.

Any other sage advice regarding this type of app would
also be appreciated.

Thanks in advance,

Morgan Leppink
..
Jul 21 '05 #1
1 2121
In order to pinpoint what is happening, you will need to debug this
application. The best way is to attach a debugger of choice to the service,
and break in from time to time to see what the threads are doing. Are they
managed threads executing code in your application ? If so, that might give
you an idea of what code in your application is responsible.

On the other hand, if the Taskmanager is showing a lot of threads, but the
debugger does not show any managed code executing on them, it might be CLR
threads. Then you will have to do some native debugging (using windbg for
example) and see what each of those threads are doing.

Also, do you create threads explicitly, either through ThreadPoo.*
functions, or creating a new Thread object in CLR ?

--
Remove "user" from the email address to reply to the author.

This posting is provided "AS IS" with no warranties, and confers no rights

Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Morgan Leppink" <ml******@equisoft.net> wrote in message
news:01****************************@phx.gbl...
Hi all -

We have been developing a complex TCP socket communication
app that is responsible for keeping numerous connections
open to clients on routable IPs. The app receives request
on a non-routable listener socket that marshals
communications between the non-routable netowrk and the
clients out on the routable network.

The app runs as a .NET service in Win2K Server. Async
sockets are being used, with BeginSend(), BeginReceive(),
EndSend(), EndReceive(), etc. Please correct me if I'm
wrong, but our understanding is that these async events
execute on a thread provided by a thread pool created by
the OS.

Operationally, the app is doing exactly what it designed
to do, BUT, the total thread count for the application
gradually rises over time (as displayed by Task Manager).
It starts out at about 18 threads, but after 24 hours it's
up to over 60 threads, and it keeps rising from there.

As expected with an async app, the number of threads does
not have a direct relationship to the number of open
connections. However, it is the marshalling of numerous
TCP messages that seems to make the thread count rise.
The marshalling of messages is when those asynch events
fire, and so I assume that the OS is creating additional
threads from the pool when they are not neccesary for the
operation of the app.

I ALSO assume that we have a bug somewhere. What I am
looking for are likely causes of the OS continuing to
assign additional threads from the pool to my process -
for example, what types of cleanup failures would cause
this? What if EndSend() did not get called properly? The
app is huge, so I would like to narrow it down to the most
likely culprit(s) so we can track this down.

Any other sage advice regarding this type of app would
also be appreciated.

Thanks in advance,

Morgan Leppink
.

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: brendonlam | last post by:
Hi there, Hoping someone could advise me here pls; I'm creating a C# class that implements a telnet client socket allowing a VB . NET application to communicate with telnet servers. After...
4
by: Matthew Groch | last post by:
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...
7
by: Doug Thews | last post by:
I saw something interesting when testing my multi-threaded code to make sure that threads were terminating as I expected. When I first bring up my WinForms test application (before I do any...
1
by: Morgan Leppink | last post by:
Hi all - We have been developing a complex TCP socket communication app that is responsible for keeping numerous connections open to clients on routable IPs. The app receives request on a...
2
by: Abubakar | last post by:
Hi, In native/unmanaged vc2k5, I want to get the thread count of my process. What apis do I have to use to get the thread count? Regards, Ab.
5
by: zxo102 | last post by:
Hi, I am doing a small project using socket server and thread in python. This is first time for me to use socket and thread things. Here is my case. I have 20 socket clients. Each client send a...
1
by: fniles | last post by:
I am using VB.NET 2003 and a threadpool. In a threadpool, is there any way to find out the thread count or some kind of thread identity ? Thank you. Dim clsEachMessage As New EachMessage...
2
by: Amit Dedhia | last post by:
Hi I am developing a scientific application which has moderate level image processing involved. In my application, there is a main application form which invokes another form. When this form...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.