Recently I proposed running Nginx rather than Apache as the frontend web server for a soon to deployed Rails app that shall remain nameless. The response I received was that Nginx was unknown and likely introduced security risks. My response was, "maybe, but Nginx is faster and uses less server resources". To which I was ordered... "prove it".
And so I did, by setting up my Rails app on a local server with all things being the same but switching the frontend servers (Nginx, Apache) and running a set of performance tests. The results were interesting and I was able to create some pretty graphs of the results.
First a word on my methods.
The intent was not to strip down the servers to only Apache vs. Nginx. Instead I wanted to find out which server gave better performance with respect to the Rails app it was serving up. This particular Rails app is running 4 mongrels, ferret server, memcache, mysql, firebird and monit. The testing server was minimal and in no way represents a true production machine, but as long as the environment was the same between test runs I assume the results should be valid. This particular server is a VM with 512 mem. Both Nginx and Apache2 were straight installs from the Debian Lenny distro, no additional modifications were made beyond the necessary steps to get the app running. The performance tests were run from a seperate machine on our local network.
Next I wanted to test 3 different types of traffic to the application. First I wanted to test the full Rails stack, that is - a request that used sessions, logging and some template rendering. Second was a stripped Rails request - no session, logging or template rendering. A simple request that replied a bit of text but required the mongrels to run the Rails code. The last test, mostly for baseline purposes, was a run on the 404.html file - to see how the two servers match up when serving static content.
I ran tests using Apache Bench and Httperf as I wanted to try out the two and see if one was better. The result was that neither was necessarily better. AB was more reliable to return a result set, but Htpf gave more data. Probably I'll keep working with both and learn more about how to configure them. For now I find them equally useful. For the test results I'll indicate which tool was used.
The Results
First is the applications index page to test the full Rails stack. This was an AB test. As can be seen in the graph below - the results are very close. I interpret this result to mean that the Rails app is keeping the performance from either web server from being a factor.
full Rails stack comparison
Next is the simplified call to the Rails stack. This is also an AB test. Now we're seeing something. Clearly Nginx is doing it's business at a far faster rate than Apache.
What is also interesting, but not seen since the data was not capture by either test tool, was the memory usage. Apache used mass quantities of memory - in fact there were several occasions when the entire swap was consumed and I needed to reboot the server. Nginx did grow in memory footprint under load but it generally hit a max load point and never overloaded the server.
minimal Rails request
Finally we have the static content performance tested vi AB. Now we see the knock-out blow. Nginx takes the gloves off and handily beats Apache in this round serving over 6 times the number of requests.
static content comparison
At this point I was able to convince people that giving Nginx a trial run was a good idea. But I didn't stop there, since I like making graphs. I made this chart of the transfer rates as measured by AB during the static content tests.
throughput
The last graph I have is from Htpf of the minimal Rails test. The nice part about Htpf is that it gives you the standard deviation, which I appreciate. This really just underscores Nginx's victory. Not only does Nginx provide better reply rates but the std dev is down near zero.
httperf reply rate averages with std dev
So there you have it, make of it what you will. I don't intend to mean this is the end-all comparison. Apache has some nice features and I'll continue to use it. For example, getting PHP running on Apache is much easier than on Nginx. On the other hand, configuring Nginx for Rails is easier than with Apache.
Of course this shouldn't replace your own testing. YMMV. But for my part, I'll recommend Nginx for running Rails until a better option is presented.
Lambda expressions and anonymous methods in C# are more complicated than you probably think. Microsoft points out that an incomplete understanding of them can result in "subtle programming errors". After running into exactly that, I'd agree. While I haven't tried it, Lambda expressions in C# 3 are supposed to do exactly the same thing.
Ever use a magnifying glass to smoke something? Ever wonder what a really, really big lens could do? Dr. Blip wondered too, and when he saw a three-by-four-foot Fresnel lens offered by American Science and Surplus, he just had to see what it would do to a hard drive. Here are the results, in the first of a series of “Will it Burn” videos, wherein we explore the combustibility of various items in the safety of the Nevada desert. Yes this is a knock-off of –er-- inspired by “Will it Blend” – and it’s much, much more fun (and more dangerous, as you will see in the out-take).
Enjoy this first installment, and please post your comments. We’re interested in your feedback, including ideas about what to “focus” on next.
Please note: no live PC components were harmed in the making of this film.
This post is a bit of a change for me. I'm actually going to write about my work for PC-Doctor! I'm actually a bit embarrassed at how rare that's been.
I want to talk about how to design a brand new framework. It's not something that everyone has to do, and it's not something that anyone does frequently. However, there's very little information on the web about the differences between creating a library and a framework.
This morning, I came across Brian White's blog post praising Best Buy for their efforts to connect their customers with a Geek Squad branded http://fixya.com site. It is a model built upon the backs of thousands of technical support evangelists operating under web 2.0 do-goodisms and according to fixya.com since 2006, their site has grown to over 700,000 pages.
While I find it quite interesting, I just don't get it. What motivates these do-gooder techs to spend their evenings and weekends helping strangers?
The next C++ standard (C++0x) will have lambda expressions as part of the standard. N2550 introduces them. It's a short document, and it's not too painful to read. Go ahead and click it.
Like many new C++ standards, it's not clear yet how the new feature is going to be used. Michael Feathers has already decided not to use them. At least one other person seems to mostly agree. I, on the other hand, am with Herb Sutter who seems excited enough about the feature to imply that MSVC10 will have support for it. This is going to be a great feature. Incidentally, Sutter has mentioned an addition to C++/CLI in the past that would add less sophisticated lambda support for concurrency. I suspect he's serious about adding the support soon.
There have been many times when I've desperately wanted to avoid defining a one-off functor or function in my code. In fact, there have been times when I've been desperate enough to actually use Boost.Lambda! This standard is a clear win over Boost's attempts to deal with the limitations of C++03.
Basically, KDE Linux will be distributed for free to "53,000 labs serving some 52,000,000 students" in the public educational system of Brazil. These posts contain links to the actual project including the proposed software offerings and screenshots of the very clean desktop interface.
I was immediately struck by how ground-breaking this is, then I started thinking about Microsoft. For a company that earns about a gillian in revenue each year, they really haven't stepped up to the plate when it comes to education. I mean they may offer student discounts or some similar middle ground capitulation, but certainly no free hand-outs!
Who stepped up to the plate?? The open source community.
What does this mean for the open source community? More importantly, what does this mean for Microsoft? With the open source movement gaining steam at an exponential pace, how much heat (if any) is Microsoft feeling from it. One thing is for sure, you won't see Microsoft bundled on any lab systems in Brazilian schools any time soon!!
ECMAScript 4.0 (ES4) is on its way. This will be the next standard for JavaScript. It's not going to be usable on web pages for a while, though. In fact, I suspect I won't be using it on my web page for at least 5 years. The problem is simple: as long as people still use older browsers, you won't be able to assume that people have it.
However, the features in it are an interesting look at what the standards committee thinks is wrong with the current JavaScript. This is not a minor patch release. This is a dramatically overhaul of the current JavaScript (ES3). Oh, they've included a lot of minor things that are simply broken in ES3. These changes are certainly interesting, but today I'm going to talk about their major focus. They want to make it easier to develop large applications in JavaScript. Clearly, they understand that people are starting to develop large applications for web browsers, and they feel that there are problems with the currently available technologies for this.
I don't have any experience with developing what I'd call a large JavaScript application, but we are starting to develop an extension of PC-Doctor for Windows that uses JavaScript in numerous places to control its behavior. In my dreams, I imagine that it will eventually become a large application made up of plugins that run on JavaScript.
Let's go through the major features that the committee thinks I'll need as our technology gets bigger...
This article is going to have more questions in it than answers. It's about a problem in software development that I'm not sure I've worried about enough. I've certainly thought about it for specific cases, but this is the first time I've tried to think about the problem in general.
My main question revolves around the cost of complexity in software. There is certainly a large cost in making software more complex. Maintenance becomes more difficult. Teaching new employees about the project becomes harder. In the end, you will get fewer engineers who understand a complex project than a simple one.
Unfortunately, almost any non-refactoring work will add to the complexity of a project. However, some changes can have a large effect on the complexity in a short period of time. Adding a new library or technique to the code base, for example, will make it so that the new technology will have to be understood by people working on the project.
What I really want to know is how much can this cost of complexity be mitigated? Besides switching libraries to add, what can be done to decrease the cost? My question is based on the assumption that some complexity is essential. So, given that you're going to add a new library to the code base, for example, what can be done to reduce the cost?
Technology presents new challenges in raising well rounded kids. I think technology has always been challenging for parents even back to my grandparents days. Kids will always want to do the new and exciting things rather than what they are supposed to be doing and what is good for them. Homework and chores are always challenged by technology.
Horses and books got my grandpa in trouble. My Dad's generation was the first to have cars. When I was growing up, my parents had to deal with TV and early video games. Now my wife and I are dealing with computers, the internet, and cell phones.