[Omaha.pm] fork() only goes 2 procs at a time?

Jay Hannah jhannah at omnihotels.com
Wed Feb 22 10:25:53 PST 2006


 
Turns out open -| and open |- are NOT the same thing as fork().

Here's what I ended up with...


==============================================================
Using Perl fork()
==============================================================
> cat j2.pl
#!/usr/bin/perl

use IO::Handle;
STDOUT->autoflush(1);

my $cmd = <<EOT;
/usr/bin/time -f "%E" wget --quiet --http-user=X --http-passwd=Y URLHERE
1>/dev/null 2>>stress.log
EOT
chomp $cmd;

#$cmd = "sleep 1";

for (1..10) {
   print "launch $_\n";
   if ($pid = fork) {
      # Parent code here...
   } else {
      # Child code here...
      die "cannot fork: $!" unless defined $pid;
      `$cmd`;
      exit;
   }
}



jhannah at razorbill:~/tmp> perl j2.pl
launch 1
launch 2
launch 3
launch 4
launch 5
launch 6
launch 7
launch 8
launch 9
launch 10
jhannah at razorbill:~/tmp> 0:10.63
0:10.95
0:11.19
0:11.20
0:11.34
0:11.55
0:12.04
0:12.06
0:12.07
0:12.22



==============================================================
Using apachebench:
==============================================================
> ab -A "X:Y" -n 10 -c 10 URLHERE
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $>
apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd,
http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation,
http://www.apache.org/

Benchmarking 10.0.33.79 (be patient).....done


Server Software:        Microsoft-IIS/6.0
Server Hostname:        10.0.33.79
Server Port:            80

Document Path:          URLHERE
Document Length:        19726 bytes

Concurrency Level:      10
Time taken for tests:   13.326764 seconds
Complete requests:      10
Failed requests:        3
   (Connect: 0, Length: 3, Exceptions: 0)
Write errors:           0
Total transferred:      202544 bytes
HTML transferred:       197264 bytes
Requests per second:    0.75 [#/sec] (mean)
Time per request:       13326.764 [ms] (mean)
Time per request:       1332.676 [ms] (mean, across all concurrent
requests)
Transfer rate:          14.78 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing: 11100 12526 772.6  12880   13326
Waiting:    11098 12522 772.9  12876   13323
Total:      11100 12526 772.6  12880   13326

Percentage of the requests served within a certain time (ms)
  50%  12880
  66%  12922
  75%  13093
  80%  13284
  90%  13326
  95%  13326
  98%  13326
  99%  13326
 100%  13326 (longest request)



More information about the Omaha-pm mailing list