Axeorcat.com

Would you prefer to be an axe or a cat? That is the question. // I Code. I Sysadmin. I Beer.
April 20, 2010

Linux vs FreeBSD PHP performance

FreeBSD p04/p10 setup slower than single Linux p09 for some reason

Apache/Network seems same

From office to DC same performance on requesting small static file: ab -n 100 -c 5 http://srv/robots.txt

On each server same performance requesting a smallish text file from localhost on each machine itself : (ab -n 100 -c 5  http://dev.lan/100k.txt)

[dev-lin] Requests per second:    1821.00

[p04-bsd] Requests per second:    1113.86

[p09-lin] Requests per second:    1197.81

PG Benchp10 is much faster

pg_bench from p04 shows the p10 Freebsd db server is much faster at network queries than the p09 Linux server

Basic standalone PHP test – p04 (FreeBSD) is much faster

office -> p09  10.3 per second -   ab -n 10 -c 5 http://srv/test-pg.php?dbhost=localhost

p09 local 14 per second ab -n 10 -c 5 http://srv/test-pg.php?dbhost=localhost

p04->p09 13 per second

p04 local 80 per second!!

Full Complex Page – p09 faster

ab -n 10 -c 5 http://srv/full.php

p09 local – 2.89 per second

p04 local – 2.72 per second

Full Home Page – p09 faster

ab -n 10 -c 5 http://srv/

p04 local 1.54 per second

p09 local 2.4 per second

p09 local 2.6 per second (no open_basedir)

p04 local no openbasedir 3.88 per second

During long stress tests, with open_basedir enabled p04 at 15/85%CPU

whilst p10 is at just 6/1% CPU (user/sys)

p04 apache taking 27m / p10 pg taking 40m
p09 apache takes 29m / pg takes 26m

Tried changing accept, php settings, disabling modules etc but no effect.

BUT openbasedir did it!! Went to 3.88 per second.

So there you have it: on FreeBSD, “openbasedir” will kill your PHP performance for a complex PHP application. Disable it, and you’ll be 50% faster than Linux in this case (caveat: not a like for like comparison as the servers in this test are differently spec’d and in fact my tests elsewhere show Linux is generally faster for my uses especially if building from source).

Leave a Comment