Username / Password :   
LinuxDig.Com Technology Articles
Your Linux News and Resource Site

Getting the Performance you need with LAMP Linux, Mysql, Apache, PHP
Author: HumanX | Thursday February 05, 2004

This article is a quick overview of some of the methods I used to improve LAMP applications. Performance Information Covers how each indivual item effected the server - Kernels, Processors (HyperThreading), MySql, Zend).


Server: Red Hat 9: 

Kernal1: Stock - 2.4.20-8smp*,
Kernal2: Stock - 2.4.20-28.9smp*
DB MySql Testing : My 3.23.58, 4.1.1 (Alpha), 4.0.17 (Dev Vers)
Hardware: Dual Xeon 2.6 (*Hyperthreading Active),
1 gig ecc,
Intel Raid 5 SRC ZCR
4x15000 RPM Cheetah Ulta 320 (1 hot)
* More information later in article





For those of you who are lamp (Linux, Apache, MySql, PHP) fans, this article may be of some interest to you. I am current working on a large database which compares transaction logs (stored in MySql) to transaction text files. The MySql tables may store anywhere from 20,000 to 1,000,000 log entries and the text files from 0 - 25,000 entries on average. The MySql tables are actually 2 related tables, table 1 contains the data and table 2 contains the transactions which are joined on an indexed unique id (more later on this).

The volume of information I am dealing with and the way I deal with data comparisons requires that I develop for performance. That development also requires that the back- end software and hardware are optimized for the job.

I started first with the three versions of MySql. I had no intentions of keeping MySql 3 but I chose to keep it around for a sort of control group during the testing. First thing first. I downloaded the source for MySql 4 (both) and compiled both with optimized settings. The settings can be found on MySql's website. A small hint (-03) for the gcc flags and disabling logging will take you far, I assure you - oh, enable-assembler.

* Hyper-Threading: Hyper-Threading is a system in which each processor is treated as two. It is kind of like, between each calculation their is a little extra room for more calculations, and the processor squeezes some in there. This has to do with the overall architecture of the machine. If you want more information on this, visit Intels web site.

The general test was run SMP kernels with the MySql benchmark suite and hyper-threading turned off. I had my suspicions the hyper-threading was slowing things down. I then ran the same tests with Hyper-Threading turned on.

Hyper-Threading did not show its colors until 2.4.20-28.9 SMP was utilized for the tests. The previous Kernel actually slowed the machine down when Hyper-Threading was active. Hyper-Threading on average added a 10%-20% improvement on the systems speed and gave a whopping 50% increase on the number of connections the machine could take on the newer kernel. Hyper-Threading works, it just requires the right kernel.

Next of all of the MySql versions, MySql 4.0.17 was the fastest. On average 10% faster. But let me clue everyone one in on something, I strongly urge you to read the manuals regarding the caching variables in the MySql. When I first installed the later versions I thought they were slower then version 3. After tweaking the variables for caching, the overall speed improvement was easily 40% or better.

Last but not least, PHP. My friend, my chum, my buddy. do you want to add 5%-10% increase in speed to your server? Install the Zend Optimizer. The final optimization for the box was adding the Zend Optimizer. After all was said and done, the stock installation of my machine compared to the more optimized version of my machine, was probably about 30% faster OVERALL.

There is still plenty of areas to find more optimization for the box. First of all the later kernel have much better support for SMP, secondly, recompile my kernel for the machine type, remember, I am using stock kernels. Keep and eye on the MySql cache information and tweak over time for my environment. Also the later Kernels off better performance in multi-threading and drive I/O. I am using stock drivers for the raid and have not researched if additional drivers are available or if there any any gotchas in the Kernels for this card. Need to research this.

Summary, Hyper-Threading did not offer a performance increase on the server until a later kernel was used, so if you are using earlier Kernels, do some performance testing with Hyper-Threading turned off and then turned on. MySql 4.0 with adjusted caching variables was the clear speed winner. Lastly, the Zend Optimizer added a 5%-10% increase in speed to the overall application.

Resources
http://www.intel.com
http://www.kernel.org
http://www.redhat.com
http://www.mysql.com
http://www.zend.com (PHP Optimizer)

Article by HumanX, http://www.linuxdig.com, please feel free to use or post this article as long as the article is posted in its original form. You can contact me at LinuxDig.Com through the contact page.

DISCUSSION: lamp
The Posting Date has expired for this discussion


"Your Linux News and Resource Site"
©2003 LinuxDig.Com. LinuxDig.Com, LinuxDig and Penguin Initiative are copyrights of LinuxDig.com.
Site Hosted By Digital Environments, Inc. This Website was Created with DE-Web Version 1.9.7.4,
The Fast, Web Based - Website Design Tool, Groupware and Web Hosting System by Digital Environments, Inc.
Groupware:Project Management, Sales Tracking, Web Site Design and News / Blogger all in one package.