I have a server with Dual Xeon Quad Core L5420 running at 2.5GHz. I've been optimizing my server, and have come to my final bottleneck: PHP.
My very simple PHP script:
My not-so-scientific-because-they-don't-pay-attention-to-thread-locking-but-scientific-enough-to-give-me-a-reasonable-multithreaded-requests-per-second-result scripts:
#!/bin/bash if [ -z $1 ]; then LIMIT=10 else LIMIT=$1 fi if [ -z $2 ]; then SCRIPT="index.php" else SCRIPT=$2 fi START=$(date +%s.%N) COUNT=0 while (( $COUNT < $LIMIT )) do php $SCRIPT > /dev/null COUNT=$(echo "$COUNT + 1" | bc) done END=$(date +%s.%N) DIFF=$(echo "$END - $START" | bc) REQS_PER_SEC=$(echo "scale=2; $COUNT / $DIFF" | bc) echo $REQS_PER_SEC
#!/bin/bash if [ -z $1 ]; then LIMIT=10 else LIMIT=$1 fi if [ -z $2 ]; then THREADS=16 else THREADS=$2 fi if [ -z $3 ]; then SCRIPT="index.php" else SCRIPT=$3 fi PIDS="" echo '' > results for thread in `seq 1 $THREADS`; do ./benchmark-php $LIMIT $SCRIPT >> results & PIDS="$PIDS $!" done for PID in $PIDS; do wait $PID done RESULTS=`cat results` MATH="0" for RESULT in $RESULTS; do MATH="$MATH + $RESULT" done echo "$MATH" | bc
The result of running
./really-benchmark-php 100 8 test.php is ~137 requests per second.
Running the same script on a sqlite or mysql powered instance of Drupal returns ~1.5 req/s.
I have APC and mem_cache both installed, and I have verified that they're running on defaults. (Yes, APC's enable_cli is on, also.) Does someone know the magic "make PHP execute faster" switch?
I have an alternative configuration setup (FPM/FastCGI) that serves ~140 req/s of the MySQL Drupal install... how could that be possible if PHP itself can't even serve 2 req/s from the command line?
The result of the
ab tool feel just as low to me:
ab -n 1000 -c 100 http://x.x.x.x/ Requests per second: 683.71
ab -n 100 -c 5 http://x.x.x.x/ Requests per second: 41.38
ab -n 100 -c 10 http://x.x.x.x/drupal/ Requests per second: 0.24
ab -n 100 -c 10 http://x.x.x.x/drupal-test/ Requests per second: 4.92