nginx vs Varnish: What are the differences?
nginx: A high performance free open source web server powering busiest sites on the Internet. nginx [engine x] is an HTTP and reverse proxy server, as well as a mail proxy server, written by Igor Sysoev. According to Netcraft nginx served or proxied 30.46% of the top million busiest sites in Jan 2018; Varnish: High-performance HTTP accelerator. Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents. Varnish Cache is really, really fast. It typically speeds up delivery with a factor of 300 - 1000x, depending on your architecture.
nginx belongs to "Web Servers" category of the tech stack, while Varnish can be primarily classified under "Web Cache".
"High-performance http server", "Performance" and "Easy to configure" are the key factors why developers consider nginx; whereas "High-performance", "Very Fast" and "Very Stable" are the primary reasons why Varnish is favored.
nginx and Varnish are both open source tools. nginx with 9.11K GitHub stars and 3.44K forks on GitHub appears to be more popular than Varnish with 908 GitHub stars and 216 GitHub forks.
According to the StackShare community, nginx has a broader approval, being mentioned in 8676 company stacks & 2560 developers stacks; compared to Varnish, which is listed in 1006 company stacks and 140 developer stacks.
I am diving into web development, both front and back end. I feel comfortable with administration, scripting and moderate coding in bash, Python and C++, but I am also a Windows fan (i love inner conflict). What are the votes on web servers? IIS is expensive and restrictive (has Windows adoption of open source changed this?) Apache has the history but seems to be at the root of most of my Infosec issues, and I know nothing about nginx (is it too new to rely on?). And no, I don't know what I want to do on the web explicitly, but hosting and data storage (both cloud and tape) are possibilities. Ready, aim fire!
I would pick nginx over both IIS and Apace HTTP Server any day. Combine it with docker, and as you grow maybe even traefik, and you'll have a really flexible solution for serving http content where you can take sites and projects up and down without effort, easily move it between systems and dont have to handle any dependencies on your actual local machine.
From a StackShare Community member: "We are a LAMP shop currently focused on improving web performance for our customers. We have made many front-end optimizations and now we are considering replacing Apache with nginx. I was wondering if others saw a noticeable performance gain or any other benefits by switching."
I use nginx because it is very light weight. Where Apache tries to include everything in the web server, nginx opts to have external programs/facilities take care of that so the web server can focus on efficiently serving web pages. While this can seem inefficient, it limits the number of new bugs found in the web server, which is the element that faces the client most directly.