473,387 Members | 1,641 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,387 software developers and data experts.

how many threads? network programming design .NET

Hi

I am programming a multi-threaded asyncronous server with .NET

But when systems thread count reaches to 1350 system can't respond.

Simply my design is creating a Reading Thread after every Accept.
And creating a Writing Thread when server sends data.

Can you share your experience with me on Network Programming and
Multi-Threading.
Jul 21 '05 #1
11 1557
Parahat Melayev <pa*****@momenttech.com> wrote:
I am programming a multi-threaded asyncronous server with .NET

But when systems thread count reaches to 1350 system can't respond.

Simply my design is creating a Reading Thread after every Accept.
And creating a Writing Thread when server sends data.

Can you share your experience with me on Network Programming and
Multi-Threading.


Rather than create two threads for every network connection, use the
asynchronous calls (BeginRead etc) so that you only end up with a few
threads at a time, rather than loads of threads actively blocking on
network access.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Parahat Melayev wrote:
I am programming a multi-threaded asyncronous server with .NET

But when systems thread count reaches to 1350 system can't respond.


The more threads running on your system, the lower the ratio production
time vs. context switching time for the CPU. A good server application
only runs a limited number of threads at a time Quickly serving a few
requests is much better that very slowly serving a big number of
requests.

Consider using I/O Completion ports and / or thread pooling to manage
this. See

http://msdn.microsoft.com/library/de...completion.asp

--
Patrick Philippot - Microsoft MVP
MainSoft Consulting Services
www.mainsoft.fr
Jul 21 '05 #3
See also

http://msdn.microsoft.com/library/?u...asp?frame=true

Please note that there's no direct support for I/O Completion ports in
..Net. However, they're supported internally by some classes.

--
Patrick Philippot - Microsoft MVP
MainSoft Consulting Services
www.mainsoft.fr
Jul 21 '05 #4
Tom
Have you considered Thread Pools? Which is the recommended way of doing this.

"Patrick Philippot" <pa***************@mainsoft.xx> wrote in message news:<u2**************@tk2msftngp13.phx.gbl>...
See also

http://msdn.microsoft.com/library/?u...asp?frame=true

Please note that there's no direct support for I/O Completion ports in
.Net. However, they're supported internally by some classes.

Jul 21 '05 #5
You are probably running out of virtual address space. .NET maps each thread
to an underlying operating system thread, and allocates 1M of virtual
address space for each one. By default each app gets a max of 2G of virtual
address space from the operating system, so you are probably bumping into
this limit.

As others have mentioned, no one writes code that uses so many threads, most
of which are blocked waiting on other operations to complete. Use a
threadpool, either the .NET pool (recommended) or roll your own.
"Parahat Melayev" <pa*****@momenttech.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

I am programming a multi-threaded asyncronous server with .NET

But when systems thread count reaches to 1350 system can't respond.

Simply my design is creating a Reading Thread after every Accept.
And creating a Writing Thread when server sends data.

Can you share your experience with me on Network Programming and
Multi-Threading.

Jul 21 '05 #6
That's my gripe with .net. They made it so easy to use threads, everybody is
doing it some without the slightest clue of what is going. at least in C++
it was difficult enough that it scared people away from using it so it was
left to those few people brave and knowledgable.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"David Levine" <no****************@wi.rr.com> wrote in message
news:ed**************@TK2MSFTNGP12.phx.gbl...
You are probably running out of virtual address space. .NET maps each
thread
to an underlying operating system thread, and allocates 1M of virtual
address space for each one. By default each app gets a max of 2G of
virtual
address space from the operating system, so you are probably bumping into
this limit.

As others have mentioned, no one writes code that uses so many threads,
most
of which are blocked waiting on other operations to complete. Use a
threadpool, either the .NET pool (recommended) or roll your own.
"Parahat Melayev" <pa*****@momenttech.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

I am programming a multi-threaded asyncronous server with .NET

But when systems thread count reaches to 1350 system can't respond.

Simply my design is creating a Reading Thread after every Accept.
And creating a Writing Thread when server sends data.

Can you share your experience with me on Network Programming and
Multi-Threading.


Jul 21 '05 #7

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
That's my gripe with .net. They made it so easy to use threads, everybody is doing it some without the slightest clue of what is going. at least in C++
it was difficult enough that it scared people away from using it so it was
left to those few people brave and knowledgable.


Hah. I'm not sure that situation was any better! And I've written a lot of
win32 threaded code.

It's actually an interesting question; how much should a developer new to
..net and windows have to know about the platform it's running on, especially
when .net promises to hide those details? Or is it the developer's fault for
believing the promise?

My take is that complete platform neutrality is more of a pie-in-the-sky
goal that may one day be reached, but the current state-of-the-art is that
there are lots of fussy details that have to be dealt with, and threading
and execution-related issues are high on the list of items like that. IOW,
the more you know the better off you are.


Jul 21 '05 #8
<"Alvin Bruney [MVP]" <vapor at steaming post office>> wrote:
That's my gripe with .net. They made it so easy to use threads,
everybody is doing it some without the slightest clue of what is
going. at least in C++ it was difficult enough that it scared people
away from using it so it was left to those few people brave and
knowledgable.


I don't think keeping people away from threads in the first place is
the right solution though. They're fundamentally necessary to almost
any non-trivial application other than batch processing, IMO.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #9
For those who are interested in Threading and VBNet a message in the
language.vb newsgoup from Jason Cooke

[ANN] August 24, "Threading with Visual Basic .NET" chat

Do you have questions about how to create multi-threaded applications? Or do
you wonder about what those threads are actually doing? Then join members of
the Visual Basic team as they answer your questions about using threading
with Visual Basic .NET.

Date:
August 24, 2004
1:00 - 2:00 P.M. Pacific time
4:00 - 5:00 P.M. Eastern time
20:00 - 21:00 GMT
(For a list of local time zones relative to GMT, please see
http://msdn.microsoft.com/chats/timezones.asp.)

Outlook Reminder:
http://msdn.microsoft.com/chats/outl...ET_Aug2404.ics

Location:
http://msdn.microsoft.com/chats (then click the name of the chat to enter
the chat room)

For more information about Visual Basic .NET, see
http://msdn.microsoft.com/vbasic/
To see a list of upcoming chats or set a reminder for this chat, see
http://msdn.microsoft.com/chats.
For archives of previous chats, see
http://msdn.microsoft.com/chats/recent.asp.

Thanks!
Jason Cooke
VB.NET Team

========
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
(c) 2004 Microsoft Corporation. All rights reserved.

Jul 21 '05 #10
if i have 1000+ concurrent network connections would threadpooling still
recommended ?

Tom wrote:
Have you considered Thread Pools? Which is the recommended way of doing this.

"Patrick Philippot" <pa***************@mainsoft.xx> wrote in message news:<u2**************@tk2msftngp13.phx.gbl>...
See also

http://msdn.microsoft.com/library/?u...asp?frame=true

Please note that there's no direct support for I/O Completion ports in
.Net. However, they're supported internally by some classes.

Jul 21 '05 #11
Tom
This is the exact situation that you would want to use thread pooling
for. The computer can only do so much you don't want it bogged down
with the context switchs for over 1000 idle thread.

Richard Ajian <aj***@NOSPAMbithc.out> wrote in message news:<2p************@uni-berlin.de>...
if i have 1000+ concurrent network connections would threadpooling still
recommended ?

Tom wrote:
Have you considered Thread Pools? Which is the recommended way of doing this.

"Patrick Philippot" <pa***************@mainsoft.xx> wrote in message news:<u2**************@tk2msftngp13.phx.gbl>...
See also

http://msdn.microsoft.com/library/?u...asp?frame=true

Please note that there's no direct support for I/O Completion ports in
.Net. However, they're supported internally by some classes.

Jul 21 '05 #12

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

Similar topics

4
by: Rhamphoryncus | last post by:
First a bit about myself. I've been programming in python several years now, and I've got several more years before that with C. I've got a lot of interest in the more theoretical stuff (language...
3
by: Andreas Müller | last post by:
i need two loops that run forever. one of it receives data and stores it to a vector. the other one writes the elements of the vector to the disk. this means the vector is a receiver buffer. How...
32
by: Christopher Benson-Manica | last post by:
Is the following code legal, moral, and advisable? #include <iostream> class A { private: int a; public: A() : a(42) {}
3
by: mphanke | last post by:
Hi, I would like to implement a windows service which forks a configurable number of threads which all siten to the same port and reply to requests of different clients. How would I implement...
9
by: Arafangion | last post by:
Hello, recently I've been trying to figure out how the heck to just destroy a thread. I have since rewritten the code in question, but what I was trying to do was to use the .Abort() method, but...
11
by: Parahat Melayev | last post by:
Hi I am programming a multi-threaded asyncronous server with .NET But when systems thread count reaches to 1350 system can't respond. Simply my design is creating a Reading Thread after...
6
by: Alexander Walker | last post by:
Hello Is it inefficient to create an application that has many threads that individually may do a small amount of work over a given period of time as opposed to an application that has a...
35
by: Carl J. Van Arsdall | last post by:
Alright, based a on discussion on this mailing list, I've started to wonder, why use threads vs processes. So, If I have a system that has a large area of shared memory, which would be better? ...
167
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.