NGINX vs Apache (Pro/Con Review)
Apache Overview
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:
- 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.
- 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.
- 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.
NGINX Overview
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
Comments
Post a Comment