Ads

NGINX vs Apache (Pro/Con Review)

Apache Overview

Apache is the web server component of the popular LAMP (Linux, Apache, MySQL, PHP) stack. Though there are many other web stack components these days (e.g., NodeJS, rich clients JS frameworks, various cloud services, etc.), LAMP still remains very popular.
The Apache web server has a rich set of features that can be enabled through installing one of the approximately 60 official modules or one of the many other unofficial modules that also exist.
Over the years, Apache has developed several methods for processing web requests to improve its efficiency (mainly RAM usage and latency). In a world where ever more concurrent web requests needed to be handled by sites, and where the served page sizes got a lot bigger, these newer methodologies were necessary.
The Apache request processing methodology can be configured in one of three ways. I’ll break down the three main Multi-Processing Modules (MPMs) below:
  1. process model: This is the original “pre-fork” method; it does not scale well with many concurrent connections, as it consumes a lot of RAM and might even refuse connections at high loads. Smaller sites won’t notice this, but larger sites likely will.
  2. worker model: This creates a single control process that is responsible for launching child processes. Each child process then creates a fixed number of threads, as well as a listener thread. The listener thread listens for connections and passes them to a thread for processing when they arrive. Though this model scales much better than the pre-fork method, it can still run into scaling issues for very high-traffic sites, due to the single control process bottleneck.
  3. event model: This is similar to the worker model, but it creates one listener thread which listens for connections and passes them to a worker thread for processing. This MPM handles long-running connections much more efficiently on a single thread (KeepAlive handling). Since Apache 2.4, the event model has been deemed stable and is now also the default setting if the operating system can support it.
You can also try compile-time and run-time options for improving Apache performance

NGINX Overview

NGINX was created in response to the C10K challenge of handling at least 10,000 simultaneous client connections on a single server. NGINX uses an asynchronous, event-driven architecture to handle these massive amounts of connections. This architecture makes handling high and fluctuating loads much more predictable in terms of RAM usage, CPU usage, and latency.

The main difference between NGINX and Apache, in terms of the event models, is that NGINX does not set up extra worker processes per connection. In most cases, the recommended NGINX configuration is running one worker process per CPU, maximizing the hardware’s efficiency.
NGINX also has a rich set of features and can perform various server roles:
  • A reverse proxy server for the HTTP, HTTPS, SMTP, POP3, and IMAP protocol
  • A load balancer and an HTTP cache
  • A frontend proxy for Apache and other web servers, combining the flexibility of Apache with the good static content performance of NGINX
NGINX supports FastCGI and SCGI handlers for serving dynamic content scripts such as PHP and Python. It uses the LEMP stack: a variation of LAMP using the phonetic spelling of NGINX (Linux, “En-juhn-ex,” MySQL, PHP)

Comments

Popular posts from this blog

The Best Way To Strengthen Your Core

5 Healthy Fast-Casual Restaurants to Try

Colorado Car Insurance