Posts tagged nerds

Graphing Benchmarks


svYou know you might be a nerd if… you spend your free time writing a script to benchmark your Web site and graph the results. I’d like to say that I only spent my free time on this because Kelly and I have been sick and so we didn’t do anything this weekend but sit around, but honestly, I’ve been wanting to do it and I probably would have spent my time on it anyway.

So here’s what I did.

Your standard Web server has a tool called ab, which stands for Apache Bench(mark). What it does is simple: You give it a URL, and it will hit that Web page as many times as you tell it, and give you back all kinds of metrics about how well the page performs.

So I wrote a little script to call the benchmark tool and parse the results out into a CSV file that I could then use in Excel to generate a graph to compare how well different pages perform and how well they scale as traffic increases.

Writing and Using the Script

I originally wrote a Bash script that parsed all of the metrics into a single spreadsheet. It had some fun shell scripting, but ultimately I didn’t need all of the metrics, so I was just making my job in Excel harder. Instead, I reworked it to parse out only the average “Time per request” and throw only that measurement into the spreadsheet. Then graphing was easy.

The big problem I had was that I was limited by the shared hosting server where I rent Web space. The Bash script would crash once I got to about 400 concurrent page requests, but I wanted to test the performance with more users than that. As a solution I converted the script to a Ruby program that didn’t use any of the intermediate files and I was able to go a lot higher without problems. My server still can’t handle huge amounts of concurrent requests, so it would still fail sometimes, but I had the script handle the failures gracefully.

The end result is a Ruby script that will compare the average request time of multiple Web pages as traffic increases. It accepts a list of URLs on the command line, and increases the number of concurrent requests up to 1,000. It takes the average of 100 attempts at each concurrency level to try and get accurate readings. If a benchmark attempt fails at any of the concurrency levels, it will slowly decrease that sample size and try again, ultimately just letting Excel interpolate from the nearby data points if it fails with even a single sample. It also increases the concurrency at an increasing rate, so it doesn’t waste time on concurrency levels that aren’t significant. (Basically it increases by one user at a time until it gets to ten, and then increases by ten at a time until gets to 100, at which point it increases by 100 at a time. And so on and so on, if I were to let it run high enough.)

If you’re interested in using it to make your own awesome graphs, you’ll have to download the source code and save it into a .rb file to run it. Obviously you’ll need the Apache benchmark tool installed, also. Then you can type something like this to generate your spreadsheet:

ruby ab-time-chart.rb > google-v-bing.csv

Just an idea.

Testing with a Simple Benchmark

I’ve got some ideas of how I’m going to use this, but I needed a simple test while I was running it a ton of times to make sure it worked. So, I thought I’d compare the performance of CGI to FastCGI. I know that’s a no-brainer (the answer is in their names), but this was more about testing my benchmark script than about the actual results.

What’s being tested here is the output of a simple Web page being generated in different ways. The contents of the page in each case is simply the current Unix timestamp. The version measured by the blue line is generated by a Ruby script running over CGI, the red line is the same Ruby code running over FastCGI, and the green line is a static HTML version that I threw in just for comparison.

The graph shows the time (in milliseconds) that it took to generate the page as traffic increased. The lower lines mean it’s faster.

Performance and Scalability of HTML, CGI, and FastCGI

No big surprises here. Obviously the static HTML version is fastest, followed by FastCGI, and CGI being the slowest. I was a little surprised by how constant the increase was, especially with FastCGI, but there’s no missing data points there. I did notice during my many (many) different runs as I was tweaking my script that a higher sample rate generally produced straighter lines. I think they probably scale pretty linearly, and any bumpiness is due to unrelated activity on my server.

So, there you have it. I’ve you’ve managed to read until the end of this post, I congratulate you on finishing my first blog post that really gives details about how big of a computer nerd I am. Sorry in advance, but it probably won’t be the last.

The Life and Death of the Darth Cannon


A little over a month ago my ward had a dumb activity in which I didn’t want to participate. So, instead of going to the activity, Tyler and I built a gun.
My friend Ryan and I had built a potato gun in high school, and I think Tyler had done the same, so we both knew the basic operations and what we needed. At the hardware store, we discovered that this is not only a very common practice, but that they don’t necessarily like helping with this, so they don’t readily sell the parts that we needed. We ended up compromising and making due with what they had, but in the process, we developed a new kind of potato cannon.
The Darth Cannon TM had a fail-safe. In the event that the pressure in the chamber was too high, instead of breaking the combustion chamber, it would blow-off the barrel to relieve the pressure. We were invincible. We couldn’t hurt ourselves with this.
So, as any good college students who had built a gun, Tyler and I did science experiments on it. (I bet you thought we were going to use it to break things, huh?) We took it to the baseball field and measured the distances it traveled with different fuel-filling styles, until we’d figured out how to best use the Darth Cannon.
Unfortunately, the Darth Cannon met its end this weekend. We’d gone up the canyon to sit around a bonfire, and I’d gotten bored. So, naturally, I pulled the Darth Cannon out of my trunk (where everyone keeps their home-made guns) and loaded it up. I readjusted the barrel because it had gotten a little crooked in my trunk, but I guess I didn’t tighten it up enough afterwards. When I shot it, instead of the potato flying out, the barrel itself shot off. This was good, of course, because it proved that my fail-safe would work, but in all of the excitement, I kind of broke off the trigger ignition that we’d put on it.



I used to have this idea of the typical RM guy (his name might be “Peter”), and I hated him: He thought he was so righteous, and that if you didn’t dress the same way that he did, he would think that you were a sinner or a bad influence, and he wouldn’t be your friend. All he ever talked about was his mission, and it often seemd as if he just wanted everyone to know how spiritual he was, so he had to remind them all of the time. It’s hard to be the punk kid around people like that, but I eventually realized that I was judging him just as much as he was me. It’s funny, but it’s possible that I was inventing that RM guy, because now I can’t find him.
I think most of the time people choose whether to be happy in a situation or not to be. It’s rare that a situation inherently makes you unhappy. Take Provo for instance. It’s easy to have a negative impression of Provo: that everyone is all stiff and nerdy, and that there’s nothing fun to do here and no cool people to hang out with. I don’t actually think that anymore. Provo’s pretty cool. I can do pretty much anything here that I can in the outside world if I want, and it being a college town adds up to a lot of cool people (both Jack and Peter) to hang out with that are in a similar stage of life as me (for the most part, anyway: I guess I am the oldest single guy in Provo).
I think the problem is that at some point people have decided that the Mormon culture is nerdy, and so they’ve decided not to be happy in it. No one can be happy if they’ve convinced themselves not to be.
Here’s what nerdy is: when you’re so into something that you can’t deal with people that aren’t into it as much as you are. I think that can apply to anything (computers, sports, music): I’m only a nerd if I belittle or otherwise can’t get along with other people that aren’t nerdy about the same thing as me. It is nerdy for people to not associate (well) with others that don’t share their religious (or other) views, but it’s not nerdy to live your religion. You can be happy with it, but it can’t make you happy or unhappy. That’s a decision you make about it.

Go to Top