Re: Thread Limits
From: Willy Denoyette [MVP] (willy.denoyette_at_pandora.be)
Date: 10/04/04
- Previous message: Imran Koradia: "Re: SystemParametersInfo Failing in VB.net"
- In reply to: Cablito: "Thread Limits"
- Next in thread: Sriram Krishnan: "Re: Thread Limits"
- Reply: Sriram Krishnan: "Re: Thread Limits"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 4 Oct 2004 22:14:13 +0200
Threads are expensive resources in Windows use them sparingly, each thread
has it's own stack space (1MB VM per default) which limits the number of
threads that can be mapped on a 2GB users memory space to about 1200-1500.
But this is a ridiculous high number which will only result in a CPU
starvation because of the extreme number of context switches, unless there
are only a few runable threads, in which case it's a waste of memory
resources.
However, to build scalable servers, you shouldn't care about threads, all
you need to apply a asynchronous programming model using the
BeginXXX/EndXXXX methods of the Socket class (or NetworkStream class).
Check the MSDN doc's for BeginAccespt/EndAccept, EndRead/BeginRead etc in
the Socket and NetworkStream class for some samples.
Also check "Using an Asynchronous Client Socket" and in general "Using
Asynchronous IO" in .NET.
Willy.
"Cablito" <cablito@dontspam.com> wrote in message
news:OiLI$SkqEHA.348@TK2MSFTNGP15.phx.gbl...
> 1º. Is there a limit for threads on Windows?
>
> I have created a test program in vb.net and it seems as if after 160
> threads
> it stalls and does not create new threads. WTF?
>
> Natural question I expect is "why in gods name do you want to create
> hundreds of threads?"
>
> I might be wrong and it might not be needed, just makes sense to me that I
> need them. I want to make a SMTP proxy, I want to listen at port 25
> internet
> address and relay to another server, inside the lan. Well, the load I need
> to handle is somewhere around 300 simultaneous users, 24 hours a day. Made
> sense to me that each "client" had a thread.
>
> Anyone?
>
>
- Previous message: Imran Koradia: "Re: SystemParametersInfo Failing in VB.net"
- In reply to: Cablito: "Thread Limits"
- Next in thread: Sriram Krishnan: "Re: Thread Limits"
- Reply: Sriram Krishnan: "Re: Thread Limits"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|