Do you have to use nginx instead of apache ?

Nginx is a open-source web server orignally created for a high-traffic russian website and while apache is good for running web servers, nginx has also his advantages.
Nginx is for sites that need fast, efficient reverse proxies or fast, efficient serving of static content. It has lower memory usage and is recommended for VPS servers.

Nginx, is an event-based web server (apache is thread-based)

You shoud use nginx if :

  • Your server is often near 100% of CPU or too much memory is used : you need the caching features of nginx to alleviate the charge
  • Your server is not suffiscient now for the amount of traffic you have, you’ll want to use then the reverse proxy to make advantage of load-balancing, url rewriting for security, and powerful caching capacity of nginx. We’ll talk about it in another article.
  • You have a LOT of static content (like images, sounds, static html etc.) and so again a nginx proxy would help you a lot
  • You are lazy to handle SSL : Nginx does it automatically for you
  • In fact, you almost ALWAYS have to use nginx if you start a new web project.

I’ll leave you with this testimony by Bob Ippolito :

The only solution I know of that’s extremely high performance that offers all of the features that you want is nginx […] I currently have nginx doing reverse proxy of over tens of millions of HTTP requests per day (thats a few hundred per second) on a *single server*. At peak load it uses about 15MB RAM and 10% CPU on my particular configuration (FreeBSD 6).

Under the same kind of load, apache falls over (after using 1000 or so processes and god knows how much RAM), pound falls over (too many threads, and using 400MB+ of RAM for all the thread stacks), and lighty *leaks* more than 20MB per hour (and uses more CPU, but not significantly more).

References :
  • https://www.wikivs.com/wiki/apache_vs_nginx
  • https://dennisforbes.ca/index.php/2013/08/07/ten-reasons-you-should-still-use-nginx/

Leave a Reply

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