Contact Menu

Apache and MySql Performance Tuning for High Traffic WordPress Website on Cpanel

SoccerNews.com is a high traffic WordPress site with over 600,000 unique visitors and over 2,000,000 page impressions per month. It is a content republisher and aggregator, presenting custom XML feeds for (what else?) soccer news from all over the world. The site has a very active user base, providing content in the forms of editorials and comments on news items. Advertising and sponsored referrals provide the revenue stream.

SoccerNews.com website

SoccerNews.com website

I was contacted by the publisher after responding to a plea for assistance in a WordPress.org support forum. Though the site was running on a dedicated server with 8GB RAM, it was crashing frequently under load. The developer tried implementing APC Alternative PHP Cache and W3 Total Cache, but these measures turned out to be incompatible with some of the custom PHP code and the software architecture of the Cpanel server. Haphazardly implementing randomly suggested “solutions” had actually made the problems worse, resulting in an “own goal” that brought down the server.

I did an assessment of the software, hardware and traffic load and found that there were many improvements to be made. Among the changes:

  • Implemented a Stateful Packet Inspection firewall and Login Failure Daemon to block malicious IP addresses, malware servers, bad bots, content scrapers, etc. Many of the problems leading to site crashes were due to constant bad bot traffic, security probes and Denial of Service attacks. Connection Tracking in the firewall now limits the amount of resources a single legitimate IP address can monopolize, in addition to blacklisting attackers.
    • This is the first step to proper web server performance in today’s Internet climate. Popular sites that do not have a solid security and load balancing strategy are subject to crippling traffic from the Internet’s millions of malicious and compromised servers and personal computers.
  • Reconfigured Apache web server, PHP and MySQL to better utilize the server’s horsepower. Cpanel’s efault Apache and MySQL configurations were limiting the number of concurrent user sessions the server could handle. Changed PHP to run as FastCGI (fcgid) and recompiled Apache to better handle the needs of a high traffic WordPress site. Configured a large MySQL table and query cache based on performance and load testing.
  • Configured Amazon CloudFront Content Distribution Network, page cache, browser cache, and object cache with the WordPress plugin, W3 Total Cache. Due to the sheer number of ad scripts being served per page, there were inevitable JavaScript and PHP conflicts, but W3TC is very flexible and was able to handle the task.
  • Suggested a scheduled, offsite backup strategy that would utilize existing resources, and eliminate the need for a 3rd-party backup solution that was causing more load issues and costing $45.00 per month.
Now the site is stable and fast, and is ready for very high traffic. With World Cup Brazil coming up in 2014, the site will definitely see a huge amount of users. Future plans include changing the architecture of the server to simplify the background processes and implement APC Alternative PHP Cache, or a caching web server front end.

Results? I’ll let the publisher speak to that!

The site has been as good as “flawless” since, with no downtime, and we couldn’t be happier. Everything is running smoothly and it’s a great relief knowing that we made the site faster, safer and more reliable. The site feels a lot more stable and faster. So you’ve done a great job. 

— Kim Vincenzius, StarScape LLC

, , , , , , , , , , , , , , , , , , , , , , ,

4 Responses to Apache and MySql Performance Tuning for High Traffic WordPress Website on Cpanel

  1. Gyanesh Sharma July 17, 2012 at 2:42 am #

    Nice article. A little more detail on how the changes were implemented would help people like me struggling to make a high traffic website faster.

  2. J MOBES May 8, 2014 at 2:28 pm #

    I am going through something similar at the moment, after changing the PHP-Handler from mod_php to SuPHP (similar to FastCGI) I notice the memory used by apache has tanked from 65+ per httpd process down to 8M/per process. However, on a pageload the PHP-Handler php-cgi will launch and consume some pretty significant memory (35+Mb each). So I’m not entirely sure if this is helping a whole lot. Any thoughts on your experience Chris?

    • Chris Gilligan May 13, 2014 at 9:26 am #

      Make sure you have plenty of MySQL cache allocated & optimized, and also rational maxclients for Apache and MySQL. Employ connection limiting via CSF or iptables. CDN all static assets. Set low execution times for PHP processes so they do not consume memory while inactive. Also run a Varnish cache in front or on top of Apache. On a web server, you should be trying to offload static assets, cache common assets/queries/objects, and only use PHP for interactive or periodic user requests. Don’t fret about the server running 80% memory capacity, if you have caches, CDN, etc. optimized.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.