| By Hovhannes Avoyan | Article Rating: |
|
| August 30, 2011 04:30 PM EDT | Reads: |
1,057 |
Apache and MySQL make up the backbone of many Linux based web servers. According to the August 2011 Web Server Survey by Netcraft, Apache currently runs on 65.18% (or 301,771,518!) of web servers. Similarly, MySQL is the most popular open source database and holds a significant portion of the market share – especially for web content. This article will detail how you can get at the ‘low-hanging fruit’ in order to make some simple changes that will yield big performance gains.
Apache Tuning
If your system is running httpd, the Apache web server, it will definitely benefit you to evaluate and modify your web server configuration to ensure that your system runs smooth. This can be an incredibly broad topic and certain an article of its own, but here are a few things you can address that can provide a big impact in your performance.
First, ensure that your MaxClients value is set appropriately for your system. This will vary based on a great many factors – what kind of content your server is serving up, the kind of PHP or other scripts you’re running, how they’re coded, etc. Here’s a quick bash one liner that will show you the average memory each httpd process is utilizing:
total=0; for memory in `ps aux | grep [h]ttpd | awk '{print $4}'`; do total=`echo "scale=2; $memory + $total" | bc`; done; echo -n "Average percentage of total memory: "; echo "scale=2; $total/ `ps aux | grep -c [h]ttpd`" | bc
This command will add up the total percentage of memory in use by all httpd processes and average it out among the number of processes. It’s certainly not perfect, but it will give you a good idea of what each process is doing. When I ran this command on one of my servers, I had an average percentage of 0.18% of total memory.
Next, you’ll want to see what your MaxClients value is set to in your Apache configuration. Let’s say it’s set to 256:
[root@server ~]# grep MaxClients /etc/httpd/conf/httpd.conf
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
MaxClients 256
To determine the maximum memory that Apache can use based on on the average memory utilization per process of 0.18%, take this value times the MaxClients setting. This gives us 46.08% of memory – well within normal limits.
For optimum performance, you’ll want to tweak Apache’s MaxClients setting such that Apache can consume no more than 70% of your available physical memory. Any higher and you risk the box starting to dip heavily into swap space, which will drastically increase IO and CPU wait and can easily cause the server to fall to its knees.
If you’re seeing very high memory utilization per process, it’s possible that it could be due to a memory leak. The best solution would be to examine your application’s code to locate and resolve the memory leak, but often this isn’t an option for system administrators. You can mitigate the damage poorly coded applications can have on your server by adjusting the MaxRequestsPerChild directive. The higher this value is set, the more requests a child process will handle before the parent process kills it off and spawns a new one. Lowering this value will cause Apache to recycle its children processes more often, freeing up memory that would otherwise be held. You’ll need to work to find a balance here as each time Apache recycles a child process it must utilize extra CPU time, so setting this value too high can cause CPU utilization issues.
It’s also a good idea to only enable the modules in Apache that are actually necessary. Depending on your installation source, you likely have several running and enabled that aren’t necessary and can in fact open up some security holes. You can check what modules are enabled by calling the Apache binary with the following options (you may need to modify the path and binary name depending on your distro):
/usr/sbin/httpd -t -D DUMP_MODULES
You’ll have many outputted and again, some research will be required to determine exactly what is necessary. For instance, you might not need the proxy_* modules – proxy_balancer, proxy_ftp_module, etc. You can often simply comment these out in your httpd configuration. The Apache httpd manual provides full information on most of these modules so you can determine their necessity: http://httpd.apache.org/docs/2.2/
Also read 25 Apache Performance Tuning Tips
Read the original blog entry...
Published August 30, 2011 Reads 1,057
Copyright © 2011 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Hovhannes Avoyan
Hovhannes Avoyan is the CEO of Monitis, Inc., a provider of on-demand systems management and monitoring software to 50,000 users spanning small businesses and Fortune 500 companies.
Prior to Monitis, he served as General Manager and Director of Development at prominent web portal Lycos Europe, where he grew the Lycos Armenia group from 30 people to over 200, making it the company's largest development center. Prior to Lycos, Avoyan was VP of Technology at Brience, Inc. (based in San Francisco and acquired by Syniverse), which delivered mobile internet content solutions to companies like Cisco, Ingram Micro, Washington Mutual, Wyndham Hotels , T-Mobile , and CNN. Prior to that, he served as the founder and CEO of CEDIT ltd., which was acquired by Brience. A 24 year veteran of the software industry, he also runs Sourcio cjsc, an IT consulting company and startup incubator specializing in web 2.0 products and open-source technologies.
Hovhannes is a senior lecturer at the American Univeristy of Armenia and has been a visiting lecturer at San Francisco State University. He is a graduate of Bertelsmann University.
- Ubuntu-based Open Source Linux Mint Tests KDE Version
- Dell and Cloudera Package Up Turnkey Hadoop
- Linux Labs Completed Development for HPC Cloud Computing Service
- The Development of a Perl-based Password Complexity Filter
- The Detested Microsoft-Novell Deal Lives On
- Oracle Makes Oracle Linux More Competitive
- Cloud Cruiser to Exhibit at Cloud Expo 2011 Silicon Valley
- Red Hat Pushes into All-Cloud Management
- Microsoft Cuts Cloud Deal with Chinese Linux Outfit
- Samba 3.6 Out
- Top 10 Reasons to Choose an Open Source Application Integration Solution
- How to Improve Server Performance by IO Tuning – Part 2
- Cloud Expo Silicon Valley Call for Papers Deadline September 16
- Xen, KVM and the Linux Choice
- Ubuntu-based Open Source Linux Mint Tests KDE Version
- Adobe AIR Dead on Desktop Linux
- Red Hat Wheels Out MRG 2.0
- Twenty-Five Linux Server Hardening Tips
- Oracle Releases VM Template for MySQL Enterprise Edition
- Dell and Cloudera Package Up Turnkey Hadoop
- Likewise Sells Heritage Assets to Go into Storage
- Nokia and Accenture Finalize Symbian Software Development and Support Services Outsourcing Agreement
- Linux Labs Completed Development for HPC Cloud Computing Service
- The Development of a Perl-based Password Complexity Filter
- The i-Technology Right Stuff
- Linux.SYS-CON.com Exclusive: Linus Discloses *Real* Fathers of Linux
- After Ubuntu, Windows Looks Increasingly Bad, Increasingly Archaic, Increasingly Unfriendly
- A Closer Look at Damn Small Linux
- Linus' Top Ten SCO Barbs
- SCO CEO Posts Open Letter to the Open Source Community
- Netscape Co-Founder's 12 Reasons for Growth of Open Source
- Where Are RIA Technologies Headed in 2008?
- *POINT - COUNTERPOINT SPECIAL* What's Wrong with the Open Source Community?
- Introducing "Cooperative Linux" - Linux for Windows, No Less
- Linux.SYS-CON.com Exclusive: What Would UserLinux Look Like?
- Why Recovering a Deleted Ext3 File Is Difficult . . .



































