Live data from Hacker News

Nginx vs Apache performance

blog.webfaction.com

31–40 of 49 posts

Re: Nginx vs Apache performance

#31
post #8

My understanding is that Nginx is the server of choice for static content and Lighttpd for dynamic content (particularly FastCGI). Is that still the latest and greatest advice? I've found Lighttpd way easier to configure than Apache and am having it serve my static content simply because we don't need to worry about every little bit of performance just yet.

Depends on the app platform. In the rails world Phusion Passenger (aka mod_rails or mod_rack) in combination with Apache is making inroads for serving up dynamic content. Despite the bigger footprint and other downsides of Apache, I'm hearing more and more that stability and ease of configuration of Passenger are a win. I'm only running it on a low usage backend app for the moment, but it was definitely easy to set u…

Passenger is a big win. I once ran nginx + mongrel_cluster, and while it probably had less overhead than the equivalent Apache + Passenger setup, it was more than cancelled out by the effort necessary to babysit the mongrel processes. This was also more of an issue with MRI-era Ruby and its associated memory leaks.

With Passenger, I set it and forget it. Time is money.

Re: Nginx vs Apache performance

#32
post #20

My understanding is that Nginx is the server of choice for static content and Lighttpd for dynamic content (particularly FastCGI). Is that still the latest and greatest advice? I've found Lighttpd way easier to configure than Apache and am having it serve my static content simply because we don't need to worry about every little bit of performance just yet.

We just use an http load balancer (haproxy) and have the app servers talk http directly. No need for a web server, which makes things much more stable. We use nginx for static content though (haproxy points at nginx for the static content).

I've found that nginx still performs around 10-15% better than haproxy. I was using the stable version of haproxy, so they may have improved speed with the experimental versions. One nice thing about nginx is that it can use local unix sockets instead of ports for load balancing. The downside of nginx is that you'll have to compile your own -- most Linux distros come with an ancient version of nginx that actually is buggy in certain ways.

Re: Nginx vs Apache performance

#33
post #19

How does Nginx compare to lighttpd?

We have used both at reddit. Performace-wise they are comparable for us, but nginx was a lot easier to configure, and lighttpd had a nasty bug that made us switch away (for the life of me though, I can't remember what the bug was).

Would that be a memory leak joke?

Re: Nginx vs Apache performance

#34
post #19

How does Nginx compare to lighttpd?

We have used both at reddit. Performace-wise they are comparable for us, but nginx was a lot easier to configure, and lighttpd had a nasty bug that made us switch away (for the life of me though, I can't remember what the bug was).

> lighttpd had a nasty bug that made us switch away

Lighttpd has a bug in mod_proxy that makes it unusable under load.

Re: Nginx vs Apache performance

#35

How does Nginx compare to lighttpd?

Both are pretty simple to configure and run. The last website I launched, I just needed something to stick in front of my process to do compression, and found out that lighttpd can only compress static files it's serving from disk. nginx can compress any input it's serving.

Re: Nginx vs Apache performance

#36
post #32
post #20

Earlier quoted context omitted.

We just use an http load balancer (haproxy) and have the app servers talk http directly. No need for a web server, which makes things much more stable. We use nginx for static content though (haproxy points at nginx for the static content).

I've found that nginx still performs around 10-15% better than haproxy. I was using the stable version of haproxy, so they may have improved speed with the experimental versions. One nice thing about nginx is that it can use local unix sockets instead of ports for load balancing. The downside of nginx is that you'll have to compile your own -- most Linux distros come with an ancient version of nginx that actually is…

Yeah, the new version of haproxy has been shown to be able to hold up on a 10Gbps connection with no problems. We're using 1.3.15.2 with a couple of patches from the experimental version.

Re: Nginx vs Apache performance

#37
post #19

Earlier quoted context omitted.

We have used both at reddit. Performace-wise they are comparable for us, but nginx was a lot easier to configure, and lighttpd had a nasty bug that made us switch away (for the life of me though, I can't remember what the bug was).

Would that be a memory leak joke?

Heh, no. But that would have been funny. Actually, teej reminded me what it was -- under heavy load, the load balancing algorithm would completely break down, and put all the traffic on the first few app servers on the list, and nothing on the last few.

Re: Nginx vs Apache performance

#38
post #34
post #19

Earlier quoted context omitted.

We have used both at reddit. Performace-wise they are comparable for us, but nginx was a lot easier to configure, and lighttpd had a nasty bug that made us switch away (for the life of me though, I can't remember what the bug was).

> lighttpd had a nasty bug that made us switch away Lighttpd has a bug in mod_proxy that makes it unusable under load.

Yeah, that was it! The load balancing algorithm completely broke down under load.

Re: Nginx vs Apache performance

#39
post #20

Earlier quoted context omitted.

We just use an http load balancer (haproxy) and have the app servers talk http directly. No need for a web server, which makes things much more stable. We use nginx for static content though (haproxy points at nginx for the static content).

How do you do process management? Do you have a static or dynamic number of app server processes/threads?

Process management is done with a custom tool. In theory we could have a dynamic number of apps, but in practice it is static. Occasionally we have to take a few out of rotation, and haproxy handles it just fine.

Re: Nginx vs Apache performance

#40
Nginx shines as a high-volume proxy, but as a straight up web server or app server, if either apache or nginx is your bottleneck, you are probably do something wrong.

At its heart nginx is a fork of apache 1.3 with the multi-processing ripped out in favor of an event loop (and all the copyright statements removed from headers, but hey, it's cool). The event loop, time and again, has been shown to truly shine for a high number of low activity connections. In comparison, a blocking IO model with threads or processes has been shown, time and again, to cut down latency on a per-request basis compared to an event loop. On a lightly loaded system the difference is indistinguishable. Under load, most event loops choose to slow down, most blocking models choose to shed load.

A few short years ago the benefits from using an event loop instead of blocking io were much more dramatic -- the level of parallelism achievable in hardware has gone way up (hey, look, erlang!) and is accelerating. Paul Tyma did some great experimentation with this a while back, http://is.gd/nJ6Z .

Post reply on HN