Papelipe / Tags / PHP



Right menu

Calendar

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

PHP

Optimizing Apache, PHP and APC for Intel based Mac

I wrote a blog last year about optimizing Apache, PHP and APC for the new Macs with Intel CPUs. At that time I could not get the ICC compiler to work in my setup, but now I have gotten the new soon to be released Intel C++ compiler version 10 from the guys at Intel and things are working much better now. I used the same machine and same setup as in my last post just with the new Intel compiler installed.
The installation itself is quite simple just click through the wizard and when you are done you need to export some environment variables and set the CC compiler variable:

source /opt/intel/cc/10.0.012/bin/iccvars.sh
export CC=/opt/intel/cc/10.0.012/bin/icc

Then you compile Apache, PHP and APC as normal. I blogged about how to compile Apache and PHP earlier.
I did the same basic test as last time but now with eZ Publish 3.9. The results when running the system with GCC:

Requests per second:    26.29 [#/sec] (mean)

With ICC compiled webserver environment I get the following results:

Requests per second:    28.85 [#/sec] (mean)

This is an additional performance improvement of 9.7% with caching enabled. When doing more CPU intensive work the difference is more noticeable so I measured template processing of a complex page before and after and this is the results:

Template processing with GCC: 1.0160sec
Template processing with ICC: 0.8382sec
% difference: 21%

This means that the CPU intensive operations with eZ Publish is boosted about 21% while the more cached operations are boosted about 10%. This is quite good especially when you consider the price Apple charges for a 20% faster CPU. The ICC compiler for Mac is selling for $399 so you have to consider the cost of the optimized software vs the cost of hardware.

UPDATE: I already did some tests with ICC using Linux 32 and 64 bits os:

Benchmark of Intel compiled Apache, PHP and APC on 64bits server

As a follow up on the ICC optimizations I did on Apache and friends and MySQL on 32 bits Intel servers I re-did the tests on 64bits servers. The test was done using Fedora Core 6 for x86_64 on a Dual Xeon 5130 2GHz.
The compilation is actually quite straight forward. You need to download and install the Intel C++ for Linux. I used the current 9.1 release of the ICC compiler. After the installation you need to export some variables:

export LD_LIBRARY_PATH=/opt/intel/cc/9.1.047/lib
export CC=/opt/intel/cc/9.0/bin/icc

Then you compile Apache, PHP and APC as normal and you are ready to run an ICC accelerated environment on your 64bits architecture.
The testing was done with eZ Publish Open Source CMS and the performance improvements was 13.4% in number of pages served and the PHP compilation speed was increased with 14.4%. This is a bit more even results than on 32bit but the overall result is better with 64bit compared to 32bits. I tested with the default download of eZ Publish 3.9.1 and used the standard MySQL that ships with Fedora Core 6. There are more tuning that can be done with the setup and the results might vary when it is tuned even more. I will look into more detailed tuning and see what numbers I can get.

Optimizing PHP for Intel based Mac

Running PHP and eZ publish on PowerPC based Macs have been extreemly slow and now that I have eZ publish running on the Intel based Mac I tried to tune it to get maximum performance out of it when running eZ publish as I was not satistied with my previous tests.

I now have 2GB of memory in the laptop I did a test similar to what I did before. I am using a different eZ publish setup which is a bit more tuned also (Yes, this is going to be released soon enough).

eZ publish 3.8 test before the patch:

Requests per second:    19.95 [#/sec] (mean)

Rasmus at Yahoo! have been using a patched version of PHP running on their FreeBSD boxes. The reason is that PHP generates lots of stat calls which really slows down the system on FreeBSD. Since OS X is based on FreeBSD I have long planned to test this patch on my system to see how it affects eZ publish. I got a ready patched version from my colleague Ole Marius, thanks ;)

The results from eZ publish after patching the system is:

Requests per second:    26.06 [#/sec] (mean)

In other words a performance boost of about 30%. Which is quite good.

When I tuned eZ publish for Linux on the Intel based platform I got good results with both Apache, PHP and APC as well as with MySQL. So I decided to get the ICC compiler for OS X and give it a shot on the Mac. After tons of warnings during compile it finally stopped with the error during linking:

icc: Command line error: invalid argument for option '-b'

If anyone knows how to make it link with icc under OS X I would be interested.

Slides for Application Clustering with MySQL & Squid

The slides for the talk I presented together with Zak on Application Clustering with MySQL & Squid is now available. The slides are in OpenDocument format so you need OpenOffice.org to view them. Any comments or suggestions welcome.
Update: slides are now also available in PDF format.

Compiling Apache and PHP on Mac OS X

Since my recent move to the Mac running OS X I have learnt some new stuff about PHP and Apache the hard way. OS X is shipped with Apache and PHP by default and if you compile Apache and PHP like you normally do under Linux you quickly get surprised. When I compile Apache I always use a prefix so I have it installed under /usr/local/apache or something like that. I like to have it installed like this so I can quickly change between Apache and PHP versions and configurations. Under OS X you quickly notice that Apache is not completely installed in the directory you added as prefix. The reason for that is that Apache has a different installation layout under OS X. So, you simply have to use the configure parameter --with-layout to make things work like you are used to.

The compilation switches I use are:

cd apache_1.3.34
make clean
./configure --prefix=/usr/local/apache \
                    --enable-module=so \
                    --enable-module=rewrite \
                    --with-layout=Apache
make
sudo make install
cd ..
cd php-4.4.2
make clean
./configure --prefix=/usr/local/apache  \
            --enable-mbstring \
            --with-apxs=/usr/local/apache/bin/apxs \
            --enable-cli \
            --enable-exif \
            --with-mysql \
            --with-mbstring
make
sudo make install 

eZ publish faster running on Intel optimized MySQL

I've done some benchmarking today with eZ publish CMS and MySQL running a process inserting articles (objects) into the CMS system. I ran the test on both the standard GCC compiled version of MySQL and the Intel ICC compiled version. The total process was 11.9% faster and the MySQL part was 20.2% faster. So atleast on heavy write operations the ICC compiled version of MySQL is running faster with eZ publish. This is good news for people running write intensive eZ publish sites. When testing with read queries I did not see that much of a difference, I will do more tests on heavy read intensive operations to find where we can gain performance also here.

Speaking at the MySQL Users Conference

I will be speaking at the MySQL Users Conference 2006 in Santa Clara on Wednesday the 26th of April.The topic of the session is Web Application Clustering with MySQL. Zak Greant will be co-presenting with me.