May 22, 2015 Jordhy Ledesma

Why Nginx?

stream

 

Nginx is a lightweight, high performance web server designed to deliver large amounts of static content quickly with efficient use of system resources. Nginx’s strong point is its ability to efficiently serve static content, like plain HTML and media files. Some consider it a less than ideal server for dynamic content. – Linode.com

 

If you’re using Apache, you’re missing out. Nginx is a small, lesser known Russian Web Server that is taking the world by storm. It’s generally faster, leaner and more logical than Apache. I seriously advocate for your consideration of migrating to Nginx.

Nginx Installed Base

Installed Base

Nginx is the most popular web server among Top 10,000 websites. Additionally, it outperforms the Apache installed base in the top 1000 websites by nearly 6 percentage points. The story here is not only about speed but also about concurrency and scalability.

Nginx Memory Usage

Memory Usage

The low memory usage of Nginx (pronounced Engine X) is simply remarkable. Memory consumption for typical pages (assuming 10K concurrents) was about 2MB for Nginx vs 200MB for Apache. That’s a 100X difference just in memory usage.

 

Unlike Apache, which uses a threaded or process-oriented approach to handle requests, Nginx uses an asynchronous event-driven model which provides more predictable performance under load. Rather than using the embedded interpreter approach, Nginx hands off dynamic content to CGI, FastCGI, or even other web severs like Apache, which is then passed back to Nginx for delivery to the client.  – Linode.com

 

Configuration Files Are Easy to Understand

Although the Apache web server is currently the most popular web server in the world, Nginx is gaining ground at a rapid rate. This is unsurprising, considering that Nginx performs excellent while using few resources. For many websites, a migration to Nginx would improve performance. – Digital Ocean Nginx Migration Guide

server {
    listen 8000;

    root /usr/share/nginx/www;
    index index.html index.htm;

    server_name localhost;

    location / {
        try_files $uri $uri/ /index.html;
    }

    location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow 127.0.0.1;
        deny all;
    }
}

But Wait There’s More

Nginx can integrate directly with Memcached and dozens of key services making your page delivery even faster and more efficient. Here’s an article describing a 53,000% performance increase after deploying Nginx and Memcached.

We switched from Apache to Nginx (“engine X”), and the benefits became immediately obvious. Nginx consumes about 2.5M of memory, and this number seems to remain basically constant over the lifetime of the process. We configured PHP to run as a FastCGI (just using the built-in PHP FastCGI server). It consumes around 32M on average, though it may go substantially higher on certain rare but intensive tasks.

In Summary

If this is the first time you’ve heard about Nginx I suggest you do some reading using this page’s resources. If you are a long-time apache advocate, I suggest you deploy an Nginx VM for some benchmarking and if you simply don’t want to change, maybe you’re in the wrong industry.


Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Email this to someone
Tagged: , ,