How to speed up Apache webserver for maximum Performance
Everyone loves a fast website. Kissmetric survey shows that 40% of people abandon a website that takes more than 3 seconds to load. Even search engines such as Google promote fast websites in their top search results.
If your web server cannot serve sites within 3 seconds, you’re at a risk of losing your hard earned business to your competitors. Speeding up your web server is vital to avoid your business going downhill.
Many web server owners contact us to help them maintain a fast web server. With our Server Administration services, we enable several online businesses to deliver blazing fast websites with a range of performance tweaks and web server tuning.
What causes slow servers?
Web servers can slow down in 2 ways – 1. Temporary sluggishness caused by some issue such as an abusive process or traffic spike. 2. Overall slowness due to improper resource management or usage.
Based on that, there are two ways in which we speed up Apache web server:
Our experts monitor customer servers 24/7. When we notice an anomaly such as a slow site speed, we immediately login to the server, kill abusive processes, and setup resource limits to prevent another such issue.
For servers that we manage, we periodically audit Apache performance. When we notice any anomaly in the server metrics, we check why the load or memory usage has gone up, track down the culprits and tweak the server settings, so that the bottleneck is removed.
We also perform Apache tuning services for server owners who contact us to speed up their web server. Today, we’ll go through the various factors we consider when tuning an Apache server.
[ You don’t have to lose your sleep to keep your web server fast and stable. Click here to keep your servers lightning fast with our Server Administration services. ]
How to speed up Apache web server?
As we all know, having enough hardware resources is indispensable for an efficient web server. A fast CPU and adequate memory (RAM) are the basic components of a high-speed Apache web server.
But you cannot guarantee a good performance out of your web server with the hardware alone, or by adding more CPU or RAM. Moreover, investing too much on hardware isn’t economically a feasible solution either.
That’s where Apache performance tuning comes into picture. With your existing hardware resources, it is possible to speed up Apache by about 50%, by tweaking the configuration settings of Apache.
Through our Specialized Server Administration services, Bobcares helps server owners deliver high uptime and performance for their websites. Here we’ll shed some light into how we do that using performance tuning.
5 step process to speed up Apache
To speed up Apache, it can be tweaked at two stages –
- During compile-time, which includes the settings used during web server install.
- At run-time, which are the parameters that have effect while running the web server.
1. Compile-time options to speed up Apache
Many often server owners install Apache using automated tools such as RPM or yum. This install has a flaw that it would be a full install, a minimal install or an install based on a predefined configuration.
While predefined or minimal installs may not give you all your required features, going for a full option install may load up the webserver files and slow it down. At Bobcares, we compile web servers for server owners based on their specific business requirement.
While going for a custom web server compilation, these points help us build a fast and efficient web server.
a. Load only the required modules
In an Apache webserver, functionalities are covered by including modules relevant for each function. These modules can be of two types – Static and Dynamic (shared).
To list the modules supported by your Apache webserver, use the command ‘apachectl -M’. While static modules are compiled into the httpd binary, dynamic modules are loaded only during run-time.
Having more static modules in the httpd binary can make it faster, but requires recompiling Apache everytime a change is needed. As a result, Dynamic modules or DSOs are now preferred more, as they can be compiled separately and loaded during run-time.
But having more dynamic or shared modules can slow down your Apache web server by about 50%, and can affect the website speed. So, caution has to be exercised while choosing the modules needed for your Apache web server.
To improve the server speed and performance, we run Apache with only the minimal required dynamic modules, as it reduces the memory footprint.
[ An expert web server tuning can save your business from going downhill. Click here to instantly speed up your web server by 50%. ]
b. Choose appropriate MPM
In Apache webserver, there are MPMs (Multi-Processing Modules) that handle the webserver connections that come to the server. MPM handles tasks such as binding to network ports on the machine, accepting connections and creating child processes.
MPMs are of two types – Prefork and Worker. In Prefork MPM, each httpd process handles one connection each. It is more fault-tolerant and secure compared to Worker, but takes up more memory and resources.
Using Worker MPM, Apache runs as a multi-threaded web server, with one thread handling each connection. This makes it suitable to handle more traffic faster and with less resource usage.
By default, most Apache software comes with the Prefork module. To speed up Apache in high-traffic servers, we switch to Worker MPM in our servers. You can identify your web server MPM using the command:
In Apache 2.4, there is support for an experimental MPM – Event MPM – that can handle multiple tasks with one thread. Hence it is even faster than the Worker MPM in handling high traffic sites with minimum memory.
We analyse the traffic projections and resource availability of each web server, and then make the decision regarding whether to choose between Worker and Prefork MPMs. We then recompile Apache with the best suited MPM.