LAMP is an acronym for a model of web service solution stacks, comprising of these components: Linux (can be Ubuntu, CentOS, etc), Apache web (HTTP) server, MySQL database and PHP programming language. This is a combination of components which is very popular and has been around for quite some time.

LEMP is pretty much similar stack of components as LAMP, except the Apache is being replaced by nginx. Pronounced "engine-x", which explain the E on "LEMP", nginx is a HTTP proxy application with reputably much smaller footprints compared to Apache, allowing it to handle higher load of HTTP requests. Nginx uses an asynchronous event driven approach to handling requests, compared to Apache's default threaded or process oriented approach, and its modular event driven architecture can provide more predictable performance under high loads.

Nginx vs Apache, which one is better?

Let me try to summarise in points on the advantage and disadvantage of using Apache and nginx.

Apache:

  • Has been available for so many years (since 1995), a lot of users and modules (mostly open-source) written to expand its functionality;
  • Process/thread-oriented approach - slows down under heavy load, need to spawn new processes and consuming more RAM, also creates new threads which have to compete for CPU and RAM resources;
  • Limit has to be set to ensure that resources are not overloaded, when the limit is reached, additional connections will be refused;
  • Limiting factor in tuning Apache: memory and potential to dead-locked threads contending for the same CPU and memory.

Nginx:

  • Open source web server application written to address performance and scalability issues associated with Apache;
  • Event-driven, asynchronous and non-blocking approach, doesn't create new processes for each web request;
  • Setting number of worker processes, and each worker can handle thousands of concurrent connections;
  • Modules are included at compile time, have internal PHP code compiler (no need for PHP module)

To conclude, nginx is faster and able to handle much higher load compared to Apache using the same set of hardware. However, Apache is still much better in terms of functionality and the availability of modules required to work with back-end application servers and to run scripting languages. So, it really depends on what you want to run on your web server.

It is actually possible to run both Apache and nginx on the same server, so you can have the best of both worlds. For example, you can run nginx as reverse proxy while Apache is running in the back-end.

Share: