Skip to content

Instantly share code, notes, and snippets.

@halcyonardency
Created August 10, 2012 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halcyonardency/3318709 to your computer and use it in GitHub Desktop.
Save halcyonardency/3318709 to your computer and use it in GitHub Desktop.
I wrote a simple PHP script to simulate activity (sleep for 500ms). I set up a vhost to handle PHP requests via mod_fcgid. I
- used PHP5.2, PHP5.3, PHP5.4 -- doesn't seem to matter.
- used the latest trunk snapshot of mod_fcgid (2.3.8), and that didn't change behavior
- used Apache 2.2.22 (and 2.2.17) with both worker and prefork mpms
Trying to figure out how to prevent serialized blocking of requests in mod_fcgid.
test.php script:
usleep(500000);
echo $_SERVER['SCRIPT_FILENAME']." :: ".$_SERVER['SERVER_NAME'];
o Loaded Apache with the worker MPM.. Used a concurrency level of 2, feeding 10 requests, we see a bottleneck due to serialization:
Concurrency Level: 2
Time taken for tests: 3.116 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Total transferred: 1560 bytes
HTML transferred: 0 bytes
Requests per second: 3.21 [#/sec] (mean)
Time per request: 623.257 [ms] (mean)
Time per request: 311.628 [ms] (mean, across all concurrent requests)
Transfer rate: 0.49 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 3 3 0.2 3 3
Processing: 504 619 336.6 505 1574
Waiting: 504 619 336.6 505 1574
Total: 507 622 336.6 508 1577
Percentage of the requests served within a certain time (ms)
50% 508
66% 508
75% 508
80% 577
90% 1577
95% 1577
98% 1577
99% 1577
100% 1577 (longest request)
o Once the processes are spun up however, we see 500ms (+~10ms overhead) for all requests as long as our concurrency does not exceed the number of child processes available
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
apache 30209 0.0 0.4 57132 8488 ? S 15:30 0:00 /usr/bin/php-cgi
apache 30214 0.0 0.4 57132 8480 ? S 15:30 0:00 /usr/bin/php-cgi
Concurrency Level: 2
Time taken for tests: 2.546 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Total transferred: 1560 bytes
HTML transferred: 0 bytes
Requests per second: 3.93 [#/sec] (mean)
Time per request: 509.200 [ms] (mean)
Time per request: 254.600 [ms] (mean, across all concurrent requests)
Transfer rate: 0.60 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 3 3 0.1 3 3
Processing: 504 506 1.7 505 509
Waiting: 504 506 1.7 505 509
Total: 507 508 1.7 508 512
Percentage of the requests served within a certain time (ms)
50% 508
66% 509
75% 509
80% 511
90% 512
95% 512
98% 512
99% 512
100% 512 (longest request)
o Adding +1 concurrency level (taking concurrency to 3), we produce a serializing bottleneck again:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
apache 30209 0.0 0.4 57132 8488 ? S 15:30 0:00 /usr/bin/php-cgi
apache 30214 0.0 0.4 57132 8484 ? S 15:30 0:00 /usr/bin/php-cgi
apache 31866 1.2 0.4 57132 8488 ? S 15:34 0:00 /usr/bin/php-cgi
Concurrency Level: 3
Time taken for tests: 2.083 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Total transferred: 1560 bytes
HTML transferred: 0 bytes
Requests per second: 4.80 [#/sec] (mean)
Time per request: 625.025 [ms] (mean)
Time per request: 208.342 [ms] (mean, across all concurrent requests)
Transfer rate: 0.73 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 3 3 0.2 3 3
Processing: 504 612 337.9 505 1573
Waiting: 504 612 337.9 505 1573
Total: 507 615 337.9 508 1576
Percentage of the requests served within a certain time (ms)
50% 508
66% 508
75% 508
80% 509
90% 1576
95% 1576
98% 1576
99% 1576
100% 1576 (longest request)
o And again, at 3 concurrency since 3 already spun up processes, no bottleneck:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
apache 30209 0.0 0.4 57132 8488 ? S 15:30 0:00 /usr/bin/php-cgi
apache 30214 0.0 0.4 57132 8484 ? S 15:30 0:00 /usr/bin/php-cgi
apache 31866 1.2 0.4 57132 8488 ? S 15:34 0:00 /usr/bin/php-cgi
Concurrency Level: 3
Time taken for tests: 2.032 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Total transferred: 1716 bytes
HTML transferred: 0 bytes
Requests per second: 4.92 [#/sec] (mean)
Time per request: 609.480 [ms] (mean)
Time per request: 203.160 [ms] (mean, across all concurrent requests)
Transfer rate: 0.82 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 3 3 0.2 3 3
Processing: 504 505 0.5 505 506
Waiting: 504 505 0.5 505 506
Total: 507 508 0.5 508 508
Percentage of the requests served within a certain time (ms)
50% 508
66% 508
75% 508
80% 508
90% 508
95% 508
98% 508
99% 508
100% 508 (longest request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment