PHP 4 vs PHP 5 Basic Benchmark

28 May

I’ve been doing some preliminary research and testing to see if upgrading to php 5 is something we want to do on WordPress.com and if so, how soon. Here are the results of a simple apache bench test of a phpinfo page. The test environment was as follows:

Hardware:

  • Dual AMD Opteron 246
  • 2GB RAM
  • 2 x 160GB SATA drives in a RAID 1 array

Software:

  • Debian Sarge AMD64
  • Litespeed 3.0.3

The tests were run from the same machine running the web server so network latency is not a factor. The test parameters were 5000 total requests with a concurrency of 100.

PHP 4.4.6 with APC 3.0.14
Concurrency Level: 100
Time taken for tests: 5.581265 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 134854586 bytes
HTML transferred: 134070000 bytes
Requests per second: 895.85 [#/sec] (mean)
Time per request: 111.625 [ms] (mean)
Time per request: 1.116 [ms] (mean, across all concurrent requests)
Transfer rate: 23595.55 [Kbytes/sec] received

PHP 5.2.2 with APC 3.0.14
Concurrency Level: 100
Time taken for tests: 8.388090 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 183254839 bytes
HTML transferred: 182470000 bytes
Requests per second: 596.08 [#/sec] (mean)
Time per request: 167.762 [ms] (mean)
Time per request: 1.678 [ms] (mean, across all concurrent requests)
Transfer rate: 21334.89 [Kbytes/sec] received

From these preliminary tests, php 5.2.2 seems about 33% slower than php 4.4.6. Surprising…

NOTE: One thing that may contribute to the apparent slowness is that the phpinfo page grew from 26814 bytes to 36494 bytes in the upgrade process.

Has anyone else run similar tests? Are the results the same?

8 Responses to “PHP 4 vs PHP 5 Basic Benchmark”

  1. Matt May 28, 2007 at 9:54 pm #

    If you’re looking for just overhead costs, do something like an echo hello world script. Real world performance on something like WP 2.2 would be more interesting overall.

  2. Barry May 28, 2007 at 9:57 pm #

    Yeah, thats next.

  3. burtonator May 29, 2007 at 5:07 am #

    Are you using include_once with full file names? If I remember correctly there was a fairly large issue with include_once, stat(), and full file names.

    Basically you can disable stat in APC and then just include it based on a unique full filename . This way php can just use the APC bytecode cache and never check to see if the file needs to be reparsed.

    You’ll have to dive into it though because I haven’t really done much performance tuning on php as everything on Tailrank is cached.

    onward.

  4. bsdguru May 30, 2007 at 6:40 pm #

    For a hello world style test just output some random data that’s the same length via a style lest for both.

  5. Zaiaku July 5, 2007 at 6:20 pm #

    PHP5 gives alot more ease for programmers. My only problem with most of it is when I use one of my other servers and they still use php4 and converting my scripts.

  6. Kumar Chetan Sharma October 26, 2007 at 10:22 am #

    I have been using PHP 4.3 most of the time, reason, production server I use only have PHP4.3. But now I am moving to PHP5. The most interesting fact about PHP5 is its support for OO. But yes, PHP5 is bit slow.

  7. maserg October 28, 2007 at 1:21 am #

    maybe APC is the problem?

    try eaccelerator instead (can work as session-data-cacher too)

  8. Federico Jaramillo September 14, 2008 at 7:22 pm #

    Found another TEST. http://www.sourcelabs.com/pdfs/SourceLabsPHP4vsPHP5.pdf

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: