PHP 5.3 vs 5.4: memory usage with and without Xcache accelerator

It's been a long time since I last posted something in my blog, so it's about time I did now.

It's been a while since PHP 5.4 was released. One of the features/improvements that was described in its release notes was the reduced memory usage when compared to v. 5.3. So, I thought about giving it a try and do some tests.

The test was focused only on peak memory usage when fullfilling a request. I used PHP versions 5.3.23 and 5.4.13 (the current stable ones in Gentoo). I also tested with and without the Xcache 3.0.1 accelerator.

I got some interesting results. See the following chart:

Peak memory usage in PHP 5.3 and 5.4 with and without Xcache

The peak memory usage is reported by xdebug_peak_memory_usage() function, rounded to megabytes. The test included requesting some sample pages from a project of mine, including database accesses, using the Yii 1.1.13 PHP framework.

My thoughts after reading the numbers:

  • PHP 5.4 has dramatically improved with regards to (peak) memory usage (look at the red and blue bars in the chart), which is what was advertised when PHP 5.4 was initially released. This will be a win win situation for all hosting providers.
  • PHP 5.3 with the help from Xcache really shines, the peak memory usage drops by a huge amount after the page is read from the cache (look at the blue and yellow bars).
  • I suppose there is room for improvement for Xcache and PHP 5.4. Of course, there is already an improvement when using xcache, but relatively to PHP 5.3 (when using Xcache) the improvement is smaller, but I guess the Xcache developer(s) can squeeze more performance out (red and green bars).
  • Currently the winner (at least with respect to memory usage) is PHP 5.3 with Xcache.

I do intend to do some tests to see the performance (requests/sec) of each version to see the differences at that field.

Feel free to comment on my results.

υπολογιστές / computers: 
Χρήσιμο / Useful: 
No votes yet
Ψηφίστε για την ποιότητα του άρθρου / Vote for the article's quality