Re: Thread Limits

From: Willy Denoyette [MVP] (willy.denoyette_at_pandora.be)
Date: 10/04/04

  • Next message: Samir Patel: "Custome Control..."
    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?
    >
    >


  • Next message: Samir Patel: "Custome Control..."

    Relevant Pages

    • Re: Thread Limits
      ... Threads are expensive resources in Windows use them sparingly, ... has it's own stack space which limits the number of ... Is there a limit for threads on Windows? ...
      (microsoft.public.dotnet.general)
    • Re: Current Directory Structure (CDS) limitations
      ... || internal stack overflow" at the 16th level. ... | not be accessed at all, if I booted to plain 4DOS, without Windows. ... I tried with LFN support both on and off. ... | limits, and enabling LFN support does not remove some of those ...
      (comp.os.msdos.4dos)
    • Re: writing overlays with VB6
      ... But there have been aditional limits in windows like system resources which disallowed programs to grow up and use all of the available virtual memory. ... only to find they confer no actual improvement whatsoever. ...
      (microsoft.public.vb.winapi)
    • Re: Virtual memory
      ... limits as recommended? ... |>> Windows help suggests putting the Page file onto the ...
      (microsoft.public.windowsxp.basics)
    • Re: Copying all files with "text" in the description
      ... By exception error, I assume that you mean it crashed 4DOS? ... it being beyond 4DOS's limits. ... I would expect an out of stack space ... I don't understand why they make gourmet cat foods. ...
      (comp.os.msdos.4dos)

    Loading