Home arrow Apache arrow Reduce Server Load for Apache and PHP Websites

Reduce Server Load for Apache and PHP Websites

This is an introductory tutorial that teaches you useful and easy practices you can use to reduce website server load. It is applicable to websites hosted on Apache web servers, preferably using Cpanel. It also assumes that you are using PHP as your server side scripting language.

  1. Reduce Server Load for Apache and PHP Websites
  2. More Tips to Reduce Server Load
By: Codex-M
Rating: starstarstarstarstar / 3
March 30, 2011

print this article



It would be a good practice as a website administrator to regularly check the server load of your website. Ideally the lower the server load, the faster your website serves content to your visitors; the faster you serve content, the faster you can increase sales, website followers, and trust.

Server Load Metrics in Cpanel

Before you begin learning these tips, it would be useful for you to know the server load metrics you need to monitor in Cpanel. To do this:

1.) Login to your Cpanel hosting account.
2.) Under “Stats” you will see lots of hosting related information such as Main Domain, Home Directory, Disk space usage and so forth. Scroll down until you see “Service Status”. Click the link “Click to View”.
3.) Under “Server Status”, you will see a lot of services in your website, alongside its status. Examples of this are imap, mysql, sshd, etc.

The following are the important metrics you need to check:

a.) Server Load – This is the load on the server CPU. The lower this figure, the better. What is acceptable varies depending on the number of CPUs your server is using. Below are some rough guidelines to judge if your website server load is normal.

To interpret the data table guide above, every hosting server may use a different number of CPUs. So for example - if your server load readings in Cpanel are 2.37 (4 CPUs), it means your website is experiencing moderate server load. Since 2.37 falls between the 1.65-2.85 range for 4cpus server, this is not yet a problem.

However if your server load data is around 4.51 (2 CPUs), then your website is experiencing high/excessive server loads. It is because 4.51 is beyond 1.9, which is the threshold for a 2 CPUs server. How frequent this happens is also very important. For example: if it reads “consistently” for 3.8 to 4.0 for a 4 CPUs server, then you need to be worry.

If it just happens very rarely, it might be a special event (like having your website featured on a front page of a high traffic website like www.yahoo.com ). Take server load readings during different times of the day, not just on one occasion.

Increasing the number of CPUs is not a permanent solution to all high server load issues. You still need to check your overall website status to make sure no web application has the possibility of abusing your server load.

b.) Memory used – generally as long as it does not stay over 85% all the time, then it is fine. High memory usage can affect server load because whenever your server is short on memory, it uses the swap file, which is essentially hard drive space (similar to the principle of page files in Windows). The more reading and writing tasks the hard drive, the higher the increase in CPU usage, which in turn increases the server load.

c.) tmp space usage (e.g. Disk /dev/sda3 (/tmp)- this is the storage space for temporary files. Sometimes when this runs out of space, a lot of your website features will be seriously affected. As long as it does not stay consistently between the 85% to 100% range, then it is fine. Contact your web host if you see above average usage.

If your website is experiencing high server load issues, I recoomend the following steps:

Reducing Server Load Tip #1: Implement Captcha on Your Website

There are malicious bots (scripts) programmed by spammers to exploit your website's features. For example if you have a useful tool on your website, not only does this attract normal visitors but spammers as well.

If your web application accepts user input and is not captcha protected, spammers can write scripts to exploit it. Once it is exploited, the user of your web application is no longer a human, but a bot. Bots can make thousands of requests in a small amount of time, which in turn increases the server load of your website.

Things you need to do:

1.) Examine all of the pages and features on your website that accept user input.
2.) Apply a captcha to these pages to ensure all users are verified humans and not bots.

For PHP, the most recommended captcha solution (which is strong and standard) is Recaptcha: http://code.google.com/apis/recaptcha/docs/php.html

Reducing Server Load Tip #2: Enable Gzip Compression

Gzip compression is very useful for reducing website bandwidth because the information that is transmitted from your server to your users is compressed or significantly reduced in size. Reducing website bandwidth can reduce the transfer times significantly, which in turn reduces server load.

Things you need to do:

1.) Check to see if you have enabled gzip compression. You can use this tool: http://www.whatsmyip.org/http_compression/

2.) Enter your homepage URL as well as one of your inner pages. If you do NOT see a result such as “http://www.example.com is gzipped” then you have not enabled Gzip on your server.

3.) To enable Gzip compression on Apache servers using Cpanel,  login to Cpanel and then go to Software/Services. Click “Optimize Website”. For the best results, select “Compress the specified MIME types”, as compressing all of your content can sometimes cause problems in your hosting configuration. Make sure all MIME types on your website are compressed to get the most benefits out of the compression.

>>> More Apache Articles          >>> More By Codex-M

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Apache Unveils Cassandra 1.2
- Apache on ARM Chips? Dell and Calxeda Help M...
- The Down Side of Open Source Software
- VMware Unveils Serengeti for Apache Hadoop
- SAP Takes Steps to Improve Hadoop Integration
- Looking to Hone Apache Hadoop Skills?
- How to Install Joomla on WAMPP
- Working with XAMPP and Wordpress
- GUI Available for Apache Camel
- Reduce Server Load for Apache and PHP Websit...
- Creating a VAMP (Vista, Apache, MySQL, PHP) ...
- Putting Apache in Jail
- Containing Intrusions in Apache
- Server Limits for Apache Security
- Setting Permissions in Apache

Developer Shed Affiliates


Dev Shed Tutorial Topics: