The easiest solution to fixing a slow server is adding more hardware in the form of RAM or CPU power. But there’s often a cheaper solution: maximizing the performance of your existing system. Below are some useful tips to speed up a Apache server.
** This article was written to optimize a Apache/Linux/Ubuntu set up (a common Apache set up) but could be used for other set ups as well
Every server install comes with a set of automatically enabled modules. Usually the more modules your server loads, the slower the server can get. This is why it’s generally a good idea to find out which modules you really use for your website(s) and apps and unload those you don't use. A good way to do this is to unload every single module one by one to find out if it affects your website or app:
Caching frequently accessed files and content can increase your server performance. One of the best Apache applications right now for this is Varnish Cache, which is completely free to use. Installing this application in front of a Apache server can speed up delivery by a stunning 1000 times (going by their own words). Go here to install the latest release on your server and here for the documentation on how to use it.
When you use a MySQL database there’s a great free little script which can be run in Apache called mysqltuner.pl. It can detect bottlenecks inside your MySQL databases. When you run the script from the command line in Apache you can instantly see where the bottlenecks occur and how you have to fix them. After that you can edit the MySQL config file (etc/mysql/my.cnf in our case) and change the necessary values to fix the bottlenecks. Go to their website to download the script and for more information on how to set it up.
When you are using PHP for your website (which is likely) you should install a PHP caching/accelerating server application. These type of applications store the compiled script bytecode in the shared memory to be able to serve it from the cache whenever website users request it. The most commonly used right now is ZEND OPcache which is automatically installed with PHP 5.5.0 and later. Go to the the website to learn how to set it up to get it working on your server.
Sometimes, especially on smaller servers with low RAM, the server can get overloaded with too many processes at the same time and slow down significantly or even hang. When this happens often to your server it’s a good idea to limit the number of processes to a number your server can handle. This way existing visitors will be able to quickly load your website. The downside is that when the limit number of processes are reached visitors will get an error and will not be able to load your site. But, and you will probably agree, this is still better than having a wesite that is extremely slow or will hang for a long period of time. Follow these steps:
We can help with that! We have professionally optimized the speed of thousands of websites. Because of this we know how to get the best results quickly while keeping our prices low. Get an instant price quote for our services now.