ScaleScaleScaleScale

Tips / Nginx


10 reasons why you should switch to Nginx

I started working with Nginx a few years ago, one of my customers requested to install Nginx on his servers and I did. However I didn’t fully understood the differences between proxy mode, stand alone Nginx , the built in load balancing, etc. It was confusing at the beginning. Why? Because I had been working with simple Apache installations since 8 years ago.

Today I’m more familiar with Nginx installations / configurations rather than Apache, because it has become my favourite webserver for all kind of things, from static, dynamic or streaming servers. And here I will tell you 10 reasons why you should switch to Nginx:

1) Easy installation and configuration

On Ubuntu/Debian:

apt-get install nginx

On CentOS/RHEL/Fedora:

yum install nginx

Configuration file is simple, you just have to edit two files max:

On CentOS /etc/nginx/nginx.conf is the main nginx configuration file, used for general directives and options. On this file you can also include your virtual hosts in this way:

include "/etc/nginx/conf.d/*.conf";

And then create virtual hosts one per file in this way:

/etc/nginx/conf.d/site1.com.conf
/etc/nginx/conf.d/site2.com.conf

No extra steps, that’s all!

2) Super fast serving static files

Why do you think most popular CDN companies use Nginx? (Cloudflare, NetDNA/MaxCDN, Cachefly, ProCDN/MediaTemple)

Nginx best possible performance can be seen while you are serving static files (zip, images files –jpg,gif,png,etc–, pdf, movie files –mp4,mpeg,avi–, html, etc). Also, if you add caching you can get a tremendous boost in your web server performance. For example:

location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}

In this example, all your .gif, .jpg, .jpeg, .png, .css, .ico and .js files are set to be cached from the next 365 days. Check out our full explanation at: How to enable Browser Cache Static Files on Nginx

3) Transform Dynamic Content into Static content

Nginx can be configured to cache dynamic proxied content with the HttpProxyModule module, allowing you to cache content efficiently without touching your application code.

4) Can handle 4x times more concurrent connections than Apache

Nginx is the most lightweight and efficient web server around. If you test it against Apache, or even against Lighttpd (anothe excellent web server) you will see the difference between concurrent connections, response times, and resource usage.There are a lot of benchmarks around showing the true and real difference between Nginx and other web servers. Just an example from DreamHost’s benchmarks on memory usage and requests per second:

memory usageconcurrent connections

As you see, in the first graph, Nginx is the webserver with less memory usage than Apache and Lighttpd. On the second graph on the right, you will see that Nginx is the one that supports more concurrent traffic (it performs better).

5) Compatible with popular web apps

WordPress, Drupal, Joomla, phpbb, vbulletin, xenforo and lot of popular web apps are running with Nginx. Are you working with python, ruby or another kind of apps? Nginx can serve traffic from any kind of applications with almost no issues at all. In the worst scenario you just have to add some rewrite rules to get it working in replacement of .htaccess files, but nowadays most popular apps include Nginx configuration guides. That’s why we have this two categories available:

6) Built in Load Balancing Support

One fanastic feature of Nginx is the ability to configure load balancing for fast scaling http servers. With Nginx Load balancing you can distribute traffic across different servers, this will let you scale your apps, and at the same time get http redundancy with an easy and quick server side setup.

If you need to read more about how to setup Nginx Load Balancing: How to configure Nginx load balancing

7) Google is looking

Almost 90% of big websites are using Nginx to serve their traffic: WordPress.com, tumblr, pinterest, instagram, yahoo, youtube, etc. As I mentioned earlier, most CDN companies use it too. If the big guys are using it there must be a very good reason, that is… website speed.

Why is website speed so important?

5 years ago website speed wasn’t so much important for SEO, but now it’s a key part of the new Internet Google wants to create. Guys at Google are right on that, Internet and the websites should be fast, quicker, not slow.

Last year Google introduced a big change in their search ranking algorithm, and that was: the speed of your web page. If your webpage is poorly optimized and it serves slow content, Google will give you less importance than faster websites, and that means less traffic from the most popular search engine on the planet. Why do you think they created Google Page Speed ? Nginx is the solution for that.

Remember that you can install Google PageSpeed on Nginx too: How to install Nginx PageSpeed module

8) Community tutorials

Feel insecure about switching to Nginx? Remember there are lot of tutorials and how to guides about Nginx, it configuration, installation and related stuff. Here you can find a lot of first step guides on Nginx:

And if that is not enough, check out Nginx’s official website with tons of docs: http://www.nginx.org

9) Professional Support

If you need enterprise support for your Nginx installations you can always get the guys from Nginx Inc to give you a hand, it’s not free, but if you have large products/websites that need a tune up, it can be a good choice to have an extra help from the official creators of Nginx.

10) Try new things! 

Get out of your confort zone: experiment, learn, make mistakes, it’s fun to learn new things in this life! That also applies to your server app stack. Get rid of that old apache server and try the new web server that is rocking the world! You’ll never regret!

 

profile

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking

  • Just Syok

    thumb up to nginx. But i need to install modsecurity as a module. So it can work with php as module…