The LEMP stack, not to be confused with the LAMP stack, has the same goal: to reliably serve your application to the world. Usually, people choose a LEMP stack because of it’s focus on being lightweight and performant.
What are the components of a LEMP stack?
Every component in the LEMP stack represents a layer of the stack, and it is crucial for the whole stack to properly work and serve the application it’s supposed to.
LEMP stack layers:
- Linux – the operating system layer
- NGINX – the webserver layer
- MySQL / MariaDB – the database layer
- PHP / Perl / Python – scripting layer
Yup, the only difference when comparing to the LAMP stack is the webserver – NGINX.
Why the need for NGINX?
Pronounced like ‘engine-ex’, it is also a webserver and also open-source, just like Apache. It can also be used as a reverse proxy, a HTTP cache, and a load balancer.
NGINX appeared as a solution to the C10k problem, which basically represented an issue with handling 10.000 concurrent connections.
Given its roots in performance under scale, Nginx most of the time outperforms other web servers. Especially in situations that have a lot of static content and a high number of concurrent requests.
So a LEMP stack is better?
I’m inclined to say yes – but I am not being fair as I manage my own servers and my costs are low as opposed to someone who has to pay for this kind of services or employ someone to do it. But there are scenarios where the advantages of Apache shine and a LAMP stack is preferred. A quick example would be that NGINX does not support something like Apache’s .htaccess file that has the advantage to give the non-privileged users control over some important aspects of their website – a common example would be changing stuff using a .htaccess file on a shared hosting environment.
But when you need raw power, serving content to A LOT of users, Nginx will not let you down. I mean… Netflix uses it, NASA uses it, WordPress.com uses it… you get it.
That doesn’t mean Apache and Nginx cannot work together! You can use Nginx in front of Apache as a server proxy to try and get the strenghts of both.
I guess the bottom line would be this: LEMP is amazing for high traffic and a lot of static content if you have a VPS/cloud/dedicated hosting environment, the knowledge or dedicated support/management. LAMP is great as an all-rounder especially if flexibility is a must. Just don’t get stuck on this if you’re just starting out.
In most common cases, your website or store can run on either stack. And before worrying about such details, get some users! Solving a problem like how can we handle this much traffic is a wonderful problem to have, as it probably means you have a great thing going – that probably makes some money too!
Tech jack of all trades. Programmer, sysadmin and a general tech enthusiast. I work with a lot of stuff, and love learning and talking about new or interesting stuff.