Posts tagged web
I wrote my Mormon.org profile about a year ago when I was starting my new job and I wasn’t sure how open I should be about my religion at work. It turns out that no one really cares much one way or the other, but it was good for me to write it. It turns out that I really like just being able to be open about who I am regardless of the circumstances.
Even though I wrote this a while ago, I don’t really have it posted or linked to anywhere. Since that website seems to be picking up speed, I figure that it’s probably time to share my profile so that people can find me on there if they’re so inclined.
So here it is: I’m Bryant, and I’m a Mormon.
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 http://www.google.com http://www.bing.com > 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.
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.
I read today about a man in Japan that was arrested (in real life) because he cheated in a video game.
Apparently we’re setting some kind of trend where virtual crimes can be punished in the real world. As long as that’s where we’re heading, I’ve composed a list of laws that need to be understood about any virtual activity.
- If there are items on the ground in a video game, to pick them up is stealing.
- Killing someone in a video game is murder.
- Killing someone on your team is treason.
- Picking to play on the side of the Germans or Russians in a video game is also treason.
- Development of a game where you can play as the Germans or Russians is considered an act of war against the US.
- The games “Grand Theft Auto” and “Thief” are completely illegal. The publishers and vendors will be prosecuted for entrapment.
- A computer virus is considered a biological weapon, and the creation of a virus will be prosecuted at an international level as the development of weapons of mass destruction.
- If your computer gets a virus you will be quarantined from the Internet (to prevent you from spreading it by your ignorance).
- Online dating services that charge for membership will be guilty of running a prostitution racket.
- You must have a license to operate an email account. If you cannot forward responsibly, then your email privileges will be forcibly revoked.
- Web pages cannot make noises or play music unless the user requests it by pressing a button. Web pages that automatically play music upon being visited will be prosecuted for disturbing the peace, and the Web pages will be impounded.
Ben’s dad got us an interview to re-make his company’s Web site. AudioDig hasn’t yet had a lot of clients, so we were pretty excited and nervous, but I think it actually went well. So with any luck we’ll have an actual paying job soon, and then I won’t sound like a liar when I tell people that I have my own Web design company.
The main page for the project that I do for BYU is finished, and today we were trying to figure out how to get the domain name pointed to it correctly, but we got it and the page is official as of today. I’ve been working on a module that sorts the images into galleries, and I finished the part that allowed a random image from the gallery to be displayed. I was uploading this just as my boss was sending out the announcement that the web site was done. You, there are several files and changes to the database that happen while I’m uploading a modification, so the web site looks screwed up for probably 2 minutes while I’m uploading things. These, of course, were the exact two minutes in which the dean of the college received the email and looked at the web page. Drama ensued.
I made a radio station, check it out: Radio Provo Platinum. Its kinda just going through my music library for now. If you’re rad, tell me and I’ll make you a DJ. Isn’t this neat?
So, this is currently a Blogger-generated page, but I host it on my own server instead of on BlogSpot, right? Well, I checked the stats for my server and it thinks that this page has been getting an average of 30 hits a day from 12 visitors per day. I think it might be broken, because no way are there that many people that visit my site. I don’t even know 12 people. Anyway, just in case, if you’re one of those 12 people (or some other poor soul that got lost here), leave a comment so I know who you are. Besides, it looks funny to always have that “0 comments” sitting there. Well, actually, I just want to feel popular by having people comment, but play along, ok?
So I tried to get this web design job today. When I talked to the owner of the store the other day she got really excited and she acted like she had already decided to have me do the site. I went back today to seal the deal, and her attitude completely changed when she realized that she was going to have to pay for it. I tried changing some options and lowering the price, but I think she just decided not to actually pay me for it. She even made some excuses about her husband or some friends making one for her for free, and I’m just like, Come on, your husband doesn’t know how to make the site that I’m trying to sell you here. Besides, who makes web sites for free anyway? Well, whoever you are, I wish you would stop, because you’re ruining my business.
I finished the Wonder Arch website yesterday. My clients seemed pleased with it but they were reluctant to say that they were, but either way, I got paid and I’m happy with how it turned out. I’m making my own spring break now, and since its not official I’m going to make it last two weeks. I’m going to go skiing tonight and tomorrow and I’m going to Denver this weekend and to Vegas the next. So there. Take that, anti-spring-break-ites.
Ok, I just got this thing to see how Blogger works and if I could steal some of its ideas for my own website(s), but I kinda like it, so maybe I’ll hang onto it.