What is a LAMP stack?
Many people in the IT World are familiar with the acronym, LAMP – which stands for Linux, Apache, MySQL and PHP. A LAMP stack is synonymous with the PHP frameworks Laravel and Symfony, both gaining increasing popularity throughout the last few years as powerhouses for web sites across the world.
Few people are aware that there is an alternative to LAMP, which is LEMP.
What is a LEMP stack?
LEMP stands for Linux, Nginx, MySQL and PHP. You may wonder how Nginx manages to represent the E in LEMP.
What does the e in LEMP stand for?
The answer is simply that Nginx is pronounced ‘Engine-X’.
Nginx is an alternative HTTP/HTTPS web server that tends to be lighter weight and historically more performant than Apache. More recently, the performance of the two servers has narrowed but that doesn’t eradicate any potential benefits and drawbacks to each of the software. Depending on the PHP web application and/or framework in use, you may find better throughput from one or the other.
“Nginx has become popular due to its event-driven design which can make better use of today’s computer hardware than Apache’s process driven design, The end result is that nginx can serve more concurrent clients with higher throughput than Apache on the same hardware.”
Itworld – Matthew Mombrea (Software Engineer)
Mombrea also stresses that is only true some of the time.
There’s very few people who wouldn’t agree that Nginx is far more efficient at serving static content than Apache. The waters get muddied when serving dynamic content comes into play. This could be PHP, Python or any of the other multitude scripting languages that are used on the back-end to generate web content, but for the purposes of this article we are concentrating on PHP.
If your server is handling a single dynamic site then it is likely that Nginx will offer better throughput and scale better than Apache. Alternatively if you are hosting multiple dynamic sites then the performance difference between the web servers is almost immaterial as PHP itself will likely become the bottleneck to site delivery.
The following quote on Quora, from Sukoon Shete sums things up nicely. “Apache is like Microsoft Word, it has a million options but you only need six,” he says. “Nginx does those six things, and it does five of them 50 times faster than Apache.”
What is the difference between LAMP stack and LEMP stack?
There are several key differences between a LAMP stack and LEMP stack.
LAMP Stack | LEMP Stack |
---|---|
Uses Apache web server | Uses Nginx web server |
Process-driven approach | Event-driven approach |
Slows under heavy load | Handles higher load of requests |
Creates new thread for each request | Handles multiple requests within a single thread |
Apache does accept additional configuration | Nginx doesn’t accept additional configuration |
Better use case for dynamic sites | Better use case for static websites |
Not as scalable | User-friendly scalability |
More features and functionality | Faster and lightweight |
Table 1: adapted from https://www.geeksforgeeks.org/
Should I choose a LAMP stack or LEMP stack?
For new sites/servers, both Apache and Nginx are powerful web servers. Therefore, choosing which to use is dependent on many things. If you are looking for a fast and lightweight server for a single site, you should go for LEMP/NGINX. If you are hosting multiple sites or require specific additional functionality on the web server software, then LAMP/Apache should be your choice.
For existing servers, the likelihood is that optimising PHP and adding the likes of APC or similar opcode cache is likely to speed things up far more than switching web server software and with far less upheaval.
<< Back to Knowledge Centre