One process doesnot support more than 100 threads?

That limitation is due to the stupidly large default stack size allocated to each thread. You can overcome that by using the stack_size => 4096 detailed in the module's POD.

This runs 500 threads, uses around 1.5 GB and heads 1000 urls in 24 seconds via my 2Mbs connection:

#! perl -slw use strict; use LWP::Simple; use threads stack_size => 4096; use threads::shared; use Thread::Queue; our $THREADS //= 500; my %log :shared; my $Q = new Thread::Queue; my @threads = map async( sub { while( my $url = $Q->dequeue() ) { my @info = head 'http://' . $url; lock %log; $log{ $url } = join $;, map{ local $^W; $_ // '*n/a*' } @info; } } ), 1 .. $THREADS; while( <> ) { chomp; sleep 1 if $Q->pending > $THREADS; $Q->enqueue( $_ ); } $Q->enqueue( (undef) x $THREADS ); $_->join for @threads; my( $url, $status ); print "$url : $status" while ( $url, $status ) = each %log; __END__ c:\test>t-head-urls -THREADS=100 urls.list.small www.t-mobile.com : text/html; charset=utf-8?109511?873075813?*n/a*?Mic +rosoft-IIS/7.0 www.avocent.com : text/html; charset=UTF-8?114030?*n/a*?*n/a*?Microsof +t-IIS/7.0 www.fsw.com : text/html?9926?1306121940?*n/a*?Apache/2.2.21 (Unix) mod +_ssl/2.2.21 OpenSSL/0.9.7a mod_auth_passthrough/2.1 mod_bwlimited/1.4 + FrontPage/5.0.2.2635 mod_fcgid/2.3.5 Resin/3.1.10 Sun-ONE-ASP/4.0.3 www.voodoopc.com : text/html?6021?*n/a*?1328712575?Apache www.creative.com : text/html; Charset=iso-8859-1?42330?*n/a*?132870531 +8?Microsoft-IIS/6.0 www.belkin.com : www.argus-systems.com : text/html?8111?1320697393?*n/a*?Apache/2.2.6 ( +Unix) mod_python/3.3.1 Python/2.5.1 mod_ssl/2.2.6 OpenSSL/0.9.8g www.iss.net : text/html; charset=UTF-8?*n/a*?*n/a*?*n/a*?Apache www.Joyent.COM : text/html; charset=UTF-8?*n/a*?*n/a*?*n/a*?Apache ...

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


In reply to Re^5: Forking Multiple Threads by BrowserUk
in thread Forking Multiple Threads by anshumangoyal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.