Motivated by migrating to new Debian v6 and Apache/PHP/MySQL combo, I have discovered interesting results about difference in performance between old v5 and v6 platform.
For comparison I have setup two platforms:
- Debian 5 (Apache/2.2.9, PHP 5.2.6-1+lenny8, MySQL 5.0.51a-24+lenny3)
Base installation + following binary packages: apache2, mysql-server, php5, php5-gd, php5-mysql, php5-cgi, php5-cli, php5-curl, php5-xcache - Debian 6 (Apache/2.2.16, PHP 5.3.3-7+squeeze1, MySQL 5.1.49-3)
Base installation + following binary packages: apache2, mysql-server, php5, php5-gd, php5-mysql, php5-cgi, php5-cli, php5-curl, php5-xcache
Each server platform has the same Drupal website. Further more each server platform has the same clean netinstall with manually installed binary packages that are needed for Drupal LAMP hosting.
I have started by measuring different memory consumption and comparing the results. The main motivation for these benchmarks is that I needed to increase the memory_limit on Debian v6 (squeeze) installation, in order to prevent memory limit exceed problem. Note that on on Debian5 memory_limit is set 128MB and on Debian6 I had to increase it (for this test I set it to 200MB).
I've searched this topic all over the Internet and drupal.org and it appears that php v5.3 is faster and better at memory consumption management. This assessment appears to be true for the most parts, which is illustrated in the following test results:
Test 1
For the first test I've chosen Performance module from Devel suite because it is utilizing memory_get_peak_usage function that is measuring exactly the thing that made me do all this.
I've installed fresh Drupal with some basic modules (admin_menu, content, filefield, imagefield, nodereference, number, optionwidgets, text, userreference, color, comment, dblog, help, menu, path, php, taxonomy, block, filter, node, system, user, performance, imageapi, imageapi_gd, pathauto, token, views, views_ui, garland)
Here are the values for memory that Performance showed for:
- node(anon) - front page as anonymous
- node - front page as admin
- modules - admin/build/modules page
- block - admin/build/block
- views - admin/build/views page
We can see that memory peaks are really bigger on php v5.3 than on php v5.2.
Test 2
Here I wanted to check general memory consumption from server point of view (opposite from memory_get_peak_usage php function). So I've used pretty basic approach - I've stressed the sites and measured how much memory apache2 process was using.
To stress I've used siege:
siege -c 1 -b -t 1m http://localhost
Results:
Debian6 (php v5.3)
Average apache2 process private memory allocation: 32.50 kb
Debian5 (php v5.2)
Average apache2 process private memory allocation: 73.60 kb
This memory allocation is combined from all apache2 processes. It showed me the thing that I've red on lots of places - php v5.3 handles memory better than php v5.2.
Test 3
To cross reference the above results, from the different approach, I've installed xdebug.
xdebug setup:
zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.profiler_output_dir = /tmp/
xdebug.profiler_output_name = cachegrind.out.%s
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 1
xdebug.show_mem_delta = 1
and hacked drupal's index.php and surrounded all the code with:
xdebug_start_trace('/tmp/mytrace');
-- code --
xdebug_stop_trace('/tmp/mytrace');
Traces are done on the same basic Drupal install. I've opened front page, loged in as admin and cleared all caches.
Because there is no easy way to get how much memory used every function call, I've used a script tracefile-analyser.php (done by derickrethans.nl) that is summing up memory and time for each functions.
Below is the table list with few functions that used most of the memory:
Here we can see that memory usage is similar. Some functions use more in older and some use more memory in newer version but overall it looks like there is not too much diferences. 0
I am going to do this benchmarks on another linux distro (with php5.3) to check it more. Also I have observed an speed performance in v5.3 as well, but did not compose the bench marking results yet.
In conclusion:
I am observing the expected decrease in memory consumption in PHP v5.3.
- I am observing an clear increase in PEAK memory consumption in PHP v5.3.
- My concern is in regard to considerable PEAK memory increase with PHP v5.3, which lasted only for microseconds, but caused the memory exceeding problem in the first place.
Did someone else encountered similar problems or benchmark results with php v5.2 vs php v5.3?
Attachment | Size |
---|---|
Selection_018.png | 76.54 KB |