Live data from Hacker News

Apache 2.4 Faster Than Nginx?

blog.zhuzhaoyuan.com

31–40 of 44 posts

Re: Apache 2.4 Faster Than Nginx?

#33

Oh hey, look. He set MaxRequestWorkers to 800. That means Apache can only process 800 connections at a time. I wonder if that will affect its performance in the benchmark.

heh, something tells me this guy will be updating his post based on all these comments. At least, I hope so.

Like spending hours digging the doc of apache just to compare it the default nginx installation ? My guess is that he will just forget apache and use nginx with default config in production and read the doc after he has a problem with it.

Re: Apache 2.4 Faster Than Nginx?

#34
Here are the relevant Apache configuration directives for this sort of benchmark of the event or worker MPM.

ServerLimit: In combination with ThreadLimit, this sets the maximum configured value for MaxRequestWorkers. Default is 16.

ThreadLimit: The maximum configured value for ThreadsPerChild for the lifetime of the Apache httpd process. Any attempts to change this directive during a restart will be ignored, but ThreadsPerChild can be modified during a restart up to the value of this directive. Default is 64.

ThreadsPerChild: The number of threads created by each child process. The child creates these threads at startup and never creates more. Default is 25.

MaxRequestWorkers: The limit on the number of simultaneous requests that will be served. Any connection attempts over the MaxRequestWorkers limit will normally be queued, up to a number based on the ListenBacklog directive. Default value is ServerLimit multiplied by the value of ThreadsPerChild, e.g. 400.

ListenBacklog: Maximum length of the queue of pending connections. Default varies by OS, on linux I think it can't be larger than /proc/sys/net/core/somaxconn

AsyncRequestWorkerFactor: Tunes the event MPM's concurrent connections per process. See http://httpd.apache.org/docs/2.4/mod/event.html Default is 2.

Re: Apache 2.4 Faster Than Nginx?

#35
post #27

Oh hey, look. He set MaxRequestWorkers to 800. That means Apache can only process 800 connections at a time. I wonder if that will affect its performance in the benchmark.

Throw in a big keepalive and on a short test you can make it so it only processes 800 requests! Awesome. Lets try this with the worker mpm instead.

The event MPM (new in Apache 2.4) is designed to address this:

This MPM tries to fix the 'keep alive problem' in HTTP. After a client completes the first request, the client can keep the connection open, and send further requests using the same socket. This can save signifigant overhead in creating TCP connections. However, Apache HTTP Server traditionally keeps an entire child process/thread waiting for data from the client, which brings its own disadvantages. To solve this problem, this MPM uses a dedicated thread to handle both the Listening sockets, all sockets that are in a Keep Alive state, and sockets where the handler and protocol filters have done their work and the only remaining thing to do is send the data to the client.

http://httpd.apache.org/docs/2.4/mod/event.html

Re: Apache 2.4 Faster Than Nginx?

#36

Earlier quoted context omitted.

Hahaha, holy jesus, I didn't realize he was running ApacheBench and the httpds on the same machine. That's insane just from a local resource starvation standpoint.

Whatever the overhead of the benchmark tool, it would be the same for Apache and nginx, presumably, so can be factored out.

How much CPU/memory is ApacheBench using? Is Apache using more CPU/memory than Nginx? Would Apache have had better performance if its resources weren't limited? Was ApacheBench able to perform as fast as possible?

It is good not to presume anything when dealing with technology.

Re: Apache 2.4 Faster Than Nginx?

#37

Note in captions: (static file) . He might as well have benchmarked Apache against an FTP server. Hitting the same HTML page/file over and over is not realistic. There is so much more to a web-server than this. What you absolutely must do is benchmark a dynamic PHP-driven, with MySQL access, website. Because that's what Apache is mostly used for (rarely for file serving). And I don't mean the first page only. But the…

I dunno, we separate out static file vs. needs-to-go-to-Tomcat requests at our HAProxy so I'm actually interested in what simply performs best serving static files. I can't imagine we're the only ones to have this need.

Re: Apache 2.4 Faster Than Nginx?

#38
post #19

Note in captions: (static file) . He might as well have benchmarked Apache against an FTP server. Hitting the same HTML page/file over and over is not realistic. There is so much more to a web-server than this. What you absolutely must do is benchmark a dynamic PHP-driven, with MySQL access, website. Because that's what Apache is mostly used for (rarely for file serving). And I don't mean the first page only. But the…

This. Good grief, what a leap of logic this entire benchmark is.

why? just because his use case is different from yours? some people use apache for fronting dynamic requests, and nginx for static serving. It would be interesting to see if apache has become competitive at serving static resources and I could drop nginx from my servers.

Re: Apache 2.4 Faster Than Nginx?

#39
post #25

Note in captions: (static file) . He might as well have benchmarked Apache against an FTP server. Hitting the same HTML page/file over and over is not realistic. There is so much more to a web-server than this. What you absolutely must do is benchmark a dynamic PHP-driven, with MySQL access, website. Because that's what Apache is mostly used for (rarely for file serving). And I don't mean the first page only. But the…

"Note in captions: (static file)... This is not realistic." It's reasonable if you're trying to test concurrent connection limits. "What you absolutely must do is benchmark a dynamic PHP-driven, with MySQL access, website." That's something nginx is also used for, and it's far from the only thing apache is used for. I agree that would be a useful benchmark, but it's not the only meaningful one. "you've only proven th…

You are dead on. If you're trying to determine which httpd is the fastest, you test it on static files. Take the dynamic part of a website out of the comparison. If you want to test something dynamic, make the test pull from many different files so that you can avoid caching.

Next, if you want to test the PHP interfaces, you can do that, but this test setup was perfectly adequate for testing the speed of the daemon. (once the configuration issues are handled)

Re: Apache 2.4 Faster Than Nginx?

#40
post #9

Apache is faster than NGINX. NGINX is faster than Apache. If that confuses you, then you don't understand http daemons. It's all about how you benchmark. This particular benchmark is 100% pointless and tells you nothing . He was performing the benchmark on one machine. In other words, all was local. You are never going to do that in production. What would be the point? In production, you have this thing called a netw…

Somebody do a benchmark with the client and server thousands of miles apart.

That is not the right way to load test. You're not trying to determine how many pages a single client can request from a server. You're trying to isolate the performance variable. To do that, you test from a machine on the same network. The resulting values are how many requests the server can handle in a given period of time, regardless of how those requests get to the server.

Post reply on HN