Apache 2.4 Faster Than Nginx?
blog.zhuzhaoyuan.com
blog.zhuzhaoyuan.com
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 network connection. It is always the limiting factor.
Somebody do a benchmark with the client and server thousands of miles apart. And tell me how much RAM and CPU is used by the daemons during the test! I am 100% sure both daemons can saturate the pipe. The relevant part is how they do that.
_ Single machine
_ Static files (seriously ?)
_ Incomplete or even incorrect configuration of Apache, I don't know for Nginx
But you know what ? That's always the same thing, people prefer to look at benchmarks, sit back in their chairs and have this immense satisfaction of not having started a project with that "slow/under-performing tool that is Apache, because Nginx is so much better". Whatever... It's really tiring.
If you were to build a real website, time delivery for static files you simply... do not care! And anyway that amount of data per sec, that rarely met. And if it's met, you rent a CDN for static content.
But as they say : "Benchmarkers are going to benchmark" (even if it's useless)
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.
False.
> You're not trying to determine how many pages a single client can request from a server.
True.
The reason you benchmark a server with a client from a thousand miles away is that you want to know what effect common Internet noise and delays will have on RAM and CPU consumption for the http daemon.
Conditions on a LAN are pretty close to ideal. Your router won't drop packets and will perform fairly well. That isn't anywhere close to true on the Internet as a whole. You do not want to push an http daemon to production that works like a champ on your LAN and has a meltdown in the real world.
You want to benchmark under as close to production conditions as you can. Period.
It is good not to presume anything when dealing with technology.
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 entire website using a stress profile that mimics real world usage (including writing to the database).
Then you'll get results that mean something.
As it is right now, this test has only proven that Nginx can handle more concurrent requests for a single static file vs. Apache 2.4 (which is something we all already know to be true).
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 that Nginx can handle more concurrent requests for a single static file vs. Apache 2.4 (which is something we all already know to be true)."
No, we didn't know this. This was testing apache 2.4's new event [0] MPM [1]. Arguably we still don't know this, since this apache configuration seems artificially limited and there's no comparison of the resource usage of apache and nginx.
[0] http://httpd.apache.org/docs/2.4/mod/event.html [1] http://httpd.apache.org/docs/2.4/mpm.html
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)
You eventually have to test the whole, not the part, unless you want to see benchmarks for useless/no-context metrics.
On the other hand I do realize its fun to see tests like this, and they can even give you a bit of insight... For example, that Apache now comes close to competing with Nginx on static loads, especially for larger files (9KB vs 54KB).
I have to imagine, that the actual 'report' was that 'apache 2.4 is faster than nginx in certain situations'. This would certainly seem to back that up: http://mondotech.blogspot.com/2012/02/apache-24-vs-nginx-ben...
Jim Jagielski is the ASF President
Source: http://www.serverwatch.com/server-news/apache-2.4-delivers-m...
Seems like it'd be a lot more constructive to say, "Hey, it's not true out of the box, but here are settings you can fiddle with that, if they work in your situation, could make Apache a better option than Nginx." Anybody want to write that blog post? :)
I'm frankly really tired of operating on cargo cult programming when it comes to my server packages. They're totally opaque to me, since they're huge pieces of software.
Is MongoDB fast? What about Riak or Couch or whatever? What does "fast" mean?
I want charts, damnit, and comparison tables with feature matrices and stuff that can used toe evaluate and, hell, I want you to put up vagrant images so I can run these tests myself.
What's important to realize about Apache 2.4 is it's probably the first version that's really C10K ready and that's a great milestone since it maintains httpd.conf and .htaccess compatibility.
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.
It'd be a better performance improvement to rewrite the stack entirely in C than change the web server and that's just illogical.
No-one (who can't afford to do their own testing) picks a webserver purely for speed.
Another problem is that the author just went with the slug WordPress proposed, which doesn't contain the question mark. This could be an oversight, but to any linkbaiters who use this tactic: I'm on to you!
That means Apache can only process 800 connections at a time.
I wonder if that will affect its performance in the benchmark.
Lets try this with the worker mpm instead.
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.
my apache is not your apache etc.
yeah, this is a web guy I'm totally going to listen to