Live data from Hacker News

Why Use Nginx?

wiki.nginx.org

81–90 of 91 posts

Re: Why Use Nginx?

#81

I think ngninx is likely faster and more stable than apache, but I have yet to see anything close to a trustworthy benchmark. I come from the php world, and people always say how much lower-memory nginx+php-fpm is than apache+mod_php. Well no doubt! If you understand how the architecture actually works, it's clear this isn't a fair comparison. mod_php means php is fully-loaded for serving statics, not to mention havi…

You may want to take a look at http://www.eschrade.com/page/why-is-fastcgi-w-nginx-so-much-.... The answer might surprise you.

As for ThreadStackSize: it impacts virtual memory but not actual memory usage. Actual memory usage stays the same. You should never use the 'vm size' as a good measurement of memory usage. Unfortunately memory management on modern OSes is complicated and people don't understand the numbers, so they arbitrarily pick a column in 'ps' and conclude that X is bloating memory... :(

Re: Why Use Nginx?

#82

Every single project, open source or not, needs to have a "Why Use It" page. (Now this is more of a "Testimonials" page, but for server tech it will do.) > Apache is like Microsoft Word, it has a million options but you only need six. Nginx does those six things, and it does five of them 50 times faster than Apache. This is exactly how I felt. I'm a pea-brained dolt in the server sphere, and when I was remaking my se…

Not just a "why use it" page, but a "what the fuck it is" page.

The number of projects I've encountered which don't even have this .... Words fail me.

Re: Why Use Nginx?

#83
post #78

Earlier quoted context omitted.

> Best of both worlds How is this best of both worlds?! You add one more layer where things can go wrong, for mostly no benefit nowadays. Now people need to know how to properly configure and secure two pieces of technology that do the same things . I know this is the most popular setup nowadays for new php deployments and this is why I hate it so much! Why does everyone have to complect anything from software to dev…

I've been using Apache behind Nginx for years, and not once has it gone wrong. HTTP reverse proxying is not something overly complicated that can go wrong often. How it is best of both worlds? Nginx simply does not have all the features Apache have. Take a look at the .htaccess rules that Wordpress and WP-Supercache needs. It's much easier to to run Wordpress on Apache and put that behind Nginx than to figure out how…

FWIW, I routinely run WP + W3TotalCache on nginx. Sure, their config files were a little interesting to get setup the first time, but now it's smooth sailing. It's only easier for Apache because the .htaccess files are readily available and ship with the product/plugin. Nginx takes a little googling to get started.

Re: Why Use Nginx?

#84

Every single project, open source or not, needs to have a "Why Use It" page. (Now this is more of a "Testimonials" page, but for server tech it will do.) > Apache is like Microsoft Word, it has a million options but you only need six. Nginx does those six things, and it does five of them 50 times faster than Apache. This is exactly how I felt. I'm a pea-brained dolt in the server sphere, and when I was remaking my se…

Not just a "why use it" page, but a "what the fuck it is" page. The number of projects I've encountered which don't even have this .... Words fail me.

The number of projects I've encountered on HN which don't even have this...

Maybe it's because I'm not a developer or working at a startup, but I get majorly annoyed whenever I click on some "Show HN" link only to be presented with a landing page on some unheard of web site that contains a few nice images and a text box wanting me to give up my e-mail address before I can even see what the application looks like or, in many cases, before I even know what the hell it is or is supposed to do!

(On a side note, that may be the longest sentence I've ever written.)

> SIGN UP NOW!

For what!?

Re: Why Use Nginx?

#85

I've used Apache exclusively for the last 3 years until just a few months ago when I set up another server to host a number of sites I wanted to move off Apache and on to Nginx. After having used both, and trying real hard here not to start a religious war as is what happens often in these kinds of discussions, I have to say neither is "better" overall or in general in my experience. If you're familiar with Apache co…

> I love being able to host multiple SSL sites on a single IP with no hoops to jump through with Nginx. On Apache your options are to acquire more IPs or set up SNI which for me was more hassle than it was worth. What? Neither Apache nor nginx can serve multiple SSL sites off a single IP without a UCC certificate, SNI, or multiple IPs. SSL requests have their Host header encrypted, which means the server doesn't know…

SNI has the problem that it's not supported on all browsers or operating systems, so even if it worked without configuration it doesn't solve the problem for most use cases. Assuming multiple subdomains on the same domain the only viable alternative to multiple IPs is to use a wildcard certificate.

Re: Why Use Nginx?

#86

One thing I still don't understand is why one would use a proxy server at all? Why not just have your load balancers (which can operate cheaply at the TCP layer) throw traffic directly at your application servers? If you need caching, that's cheap to do, too. If you need static file serving, can't you another load balancer end-point that points directly at static content servers, or make your application servers fast…

An HTTP level load balancer like nginx can do session affinity, which is helpful when your application server isn't stateless. I guess a TCP load balancer could do them based on IP as well, but IPs don't identify sessions as well as cookies can.

As can haproxy or any other L7 load balancer.

Re: Why Use Nginx?

#87

I think ngninx is likely faster and more stable than apache, but I have yet to see anything close to a trustworthy benchmark. I come from the php world, and people always say how much lower-memory nginx+php-fpm is than apache+mod_php. Well no doubt! If you understand how the architecture actually works, it's clear this isn't a fair comparison. mod_php means php is fully-loaded for serving statics, not to mention havi…

You may want to take a look at http://www.eschrade.com/page/why-is-fastcgi-w-nginx-so-much-... . The answer might surprise you. As for ThreadStackSize: it impacts virtual memory but not actual memory usage. Actual memory usage stays the same. You should never use the 'vm size' as a good measurement of memory usage. Unfortunately memory management on modern OSes is complicated and people don't understand the numbers,…

That link about AllowOverride is true. The reason I didn't mention it is that one of the benchmarks I saw did turn off AllowOverride so I figured at least that part was fair :) But it is a very good point. I think I'll do a talk soon about tuning apache and make sure that's in there. Optimizing with strace is always really fun. I used it pretty heavily when I was researching php/apc and require/require_once. It's amazing how much faster you can get if you implement things to not talk to the disk 20x on every request :)

I definitely know VIRT is complicated. I couldn't find any kind of clarity on it. If you know of a good guide I'd love to see it.

That said, virtual memory still likely affects some kernel decision-making. For instance the oom-killer was kicking in on a daily basis until I made these changes. With mpm_worker using 250+ threads, I was able to reduce the "committed" by several gigs. The system overall seems more stable and the oom-killer hasn't reared its head in days.

I can imagine that the stack is treated differently since it'd be a terrible idea to page out stack. I couldn't find proof, but if I were a kernel I wouldn't page out stack :)

Re: Why Use Nginx?

#88
post #67
post #18

Earlier quoted context omitted.

It's a good question. We (a large-scale website serving 250,000 pages/day) use Python+CherryPy for our "application server", but that's sitting behind an nginx reverse proxy. The main reason is that nginx is much better and faster at handling certain things than Python: * handling HTTPS and serving plain old HTTP to the application server so Python doesn't have to worry about it * doing the gzipping of content before…

I'm curious to know - did you consider Varnish? It's much faster as a rev proxy caching server.

No, it isn't. It claims to be faster than squid, not nginx. But it doesn't even meet that claim.

Re: Why Use Nginx?

#89

One thing I still don't understand is why one would use a proxy server at all? Why not just have your load balancers (which can operate cheaply at the TCP layer) throw traffic directly at your application servers? If you need caching, that's cheap to do, too. If you need static file serving, can't you another load balancer end-point that points directly at static content servers, or make your application servers fast…

Another reason people haven't considered here is that nginx can display error pages for you when your application server crashes, or is taking too long to serve requests. This is much nicer for the user than a browser error.

Re: Why Use Nginx?

#90
post #74

Earlier quoted context omitted.

> I love being able to host multiple SSL sites on a single IP with no hoops to jump through with Nginx. On Apache your options are to acquire more IPs or set up SNI which for me was more hassle than it was worth. What? Neither Apache nor nginx can serve multiple SSL sites off a single IP without a UCC certificate, SNI, or multiple IPs. SSL requests have their Host header encrypted, which means the server doesn't know…

Nginx can (and according to wikipedia Apache can too), I have been doing so until my old certificate expired. It's called SNI ( https://en.wikipedia.org/wiki/Server_Name_Indication ) and if your openSSL version has support compiled in, it works without any additional configuration (Beyond just normally specifying the correct certificate and key for the correct server)

Yes, that's why I mentioned SNI in my post.
Post reply on HN