Nginx vs. Apache, which is better for your WordPress site

apachevsnginx

What is Nginx and Apache

 

Nginx (Pronounced Engine-x) and Apache, both are open source web servers.

The Apache web servers are the oldest ones around. They have been in use since 1995, whereas nginx came some where around 2002. Both the products are open-source and free but if you need support for nginx you will need to buy Nginx Plus version. Nginx was written primarily to address the C10K problem and some performance and scalability issues associated with Apache.

How They Work

 

Apache

—Apache  handles HTTP Requests sent to it. It creates processes and threads to handle additional connections. The administrator can configure the server to control the maximum number of allowable processes. This configuration varies depending on the available memory on the machine. Too many processes exhaust memory and can cause the machine to swap memory to disk, thus severely degrading performance. Plus, when the limit of processes is reached, Apache refuses additional connections. Apache is comprised of Two main building Blocks with the Latter being comprised of many other little building blocks. The Building Blocks are the Apache Core and then the Apache Modules that in a sense extend the Apache core.

 

02kew01

 

 

 

Apache is like Microsoft Word, it has a million options but you only need six. Nginx does those six things, and it does five of them 50 times faster than Apache.

— Chris Lea on nginx and WordPress

 

 

Nginx

Nginx works differently from Apache, specially how it handles threads. It uses Event-driven, asynchronous, non-blocking and single threaded architecture.

  • Event Driven : The starting and completion of events are marked by notifications, therefore the resources can be used by the other process until a process start or completion notification is received.
  • Asynchronous : Threads can be run concurrently, thus they do not block each other.
  • Single Threaded :  As the resources are not blocked therefore, multiple clients can be handled by a single worker process.

The following diagram represents the Nginx architecture :

 

nginx-architecture

 

 

Pros and Cons

Apache

 Pros :

  • Large number of Modules: Apache been available since many years and  has a larger community base, therefore has lots of Open-source modules written to expand it’s functionality.
  • Open Source :  Everything  relating to Apache is free, be it there modules or there support.
  • Large number of Users : Nearly 46% of all websites run on Apache.

Cons :

  • Less Secure than nginx.
  • Requires a heavy server configuration to handle high traffic websites. Since it spawns new process threads for each request, Apache requires a high memory footprint.
 

Nginx

Pros :

  • Fast : It does not create a new process for each new request, therefore it becomes very fast.
  • Lightweight : As Nginx comes only with the core features required by the server, it makes it lightweight in comparison to Apache and hence consumes less memory as well.
  • Easy Scalability: Nginx is highly scalable, and it’s performance is not dependent on hardware.

Cons:

  • Does not support Operating Systems like OpenVMS and IBMi.
  • Limited support: The Nginx community is not as big as the Apache community and it is repetitively newer as compared to Apache, so the community is also smaller for now.

 

 Conclusion 

With the above advantages in mind, more and more people are moving towards Nginx. Even WordPress.com was shifted over to Nginx and they have thousands of servers, serving thousands of requests per second. Also Nginx has become the number 1 web server for the top 10,000 websites on the internet (Read more).

 

 

One Reply to “Nginx vs. Apache, which is better for your WordPress site”

  1. Throughout the great scheme of things you’ll get an A+ with regard to effort and hard work. Where exactly you actually lost me was in the facts. As people say, details make or break the argument.. And that could not be more accurate at this point. Having said that, allow me reveal to you just what exactly did give good results. Your article (parts of it) is really powerful which is probably why I am taking the effort to comment. I do not really make it a regular habit of doing that. Second, although I can certainly see the leaps in logic you come up with, I am not necessarily confident of just how you appear to unite the points which make the actual conclusion. For right now I shall subscribe to your issue however trust in the near future you connect your facts better.

Leave a Reply

Your email address will not be published. Required fields are marked *