If your’re PHP developer, you might have been in the confusion of choosing right PHP Web Servers for your production environment. What runs fast ? What supports concurrency most ? and What uses less resources ? Well, let’s talk about!
PHP Web Servers – What to use? when ?
The nature of your PHP application can be vary depending on your requirements and the technical perspectives. your PHP app may be written in pure PHP, or probably written on a PHP framework such as Laravel. And your Database server may be vary too. There are several options out there you can choose as per your development requirements. So, considering these, the PHP Web Servers you want can be different. So, let’s take one of them and identify pros and cons all of them has.
First of all let’s get to know the top 3 giant PHP Web Servers.
Apache2 has been up and running for quite a long time by now and has been a popular choice of developers as its convenience of installation and configuration. It was originally launched in 1995 as a result of another project. Apache was able to scale beyond 10,000 connections which also refers as C10K Problem.
NginX was first launched in 2004. It claims to have the higher performance in concurrency. And it was also able to solve the C10K Problem. It uses an approach of asynchronous event driven, to manage the requests of clients. Due to it’s high end performance, it has become the second most popular of PHP Webservers in the world.
This was launched in 2003. And it was also able to solve the C10K Problem. As its name suggests, it claims to be light-weight and low in resource consuming. However, Lighttpd is said to have some bugs regarding memory problems and leaks. Due to that, the popularity has been little lower comparing to the top 2 giants.
OK, now we have some knowledge on theses three and and their background. Now it’s time to rank them according to the performance perspective.
Memory is a top consideration of a server and it’s one of the most important concerns. Let’s find out how these web servers react on different conditions.
Memory usage on idle conditions (Approximately)
- lighttpd – Total RAM – 1.5 MiB
- apache2 – Total RAM – 14.0 MiB
- nginx – Total RAM – 15.0 MiB
Memory usage on Stressed conditions (Approximately)
- nginx – Total RAM – 17.8 MiB
- lighttpd – Total RAM – 21.7 MiB
- apache2 – Total RAM – 46.3 MiB
It’s looks like that there’s a complete turnaround of the competitors in these two tests. Lighttpd is the lightest one in idle condition of the webserver, but seems to increase memory usage more than 10 times higher when the server is in used by several heavy processes. Apache also, becomes too much is memory consumption. NginX on the other hand is a stable competitor amon gthese three as it does not move over the line even when it’s stresses. That mease NginX is much smoother and dependable in terms of memory consumption.
Let’s do another test to find out how these PHP Web Servers react to the requests load. What we check here is how each of these servers give responses for each request in a minimum period of time.
So, the following chart is the comparison of results I got for each PHP Web Servers.
So, it’s proven that Apache takes the maximum time to respond to all the requests and NginX is the on that takes least time to respond. Lighttpd is in the middle of these. So, in terms of Requests handling in PHP Web Servers, NginX wins too.
I did two important tests (Memory usage test and Requests load test) on these PHP Web Servers and from the result I got, I came to the conclusion that NginX is far too better that other competitors.
There may be additional concerns and parameters to be considered too. So, please leave a comment about what you think!