Design for Easier HTTP Load Testing

I’ve told two people about this trick in the last few days, so it is worth writing it up.

It is hard to get a good distribution of requests in your HTTP load tester, it usually requires a knowledge of valid keys or users and a model of the distribution of the accesses. This can all be built in the load tester, but that seems to be a big barrier, since I’ve rarely seen that happen. I’ve certainly never done it and I’ve needed it several times.

The easy way to do this is to add a “random choice” parameter to the app. The app already knows the legal set of keys or users and can quickly make a choice. You already know the language and the code in the app, and the changes are localized to the URL parameter parsing. Let’s say you have a back-end server that returns records.

http://example.com/getRecords?key=12345&key=67890
http://example.com/getRecords?key=random&key=random

An HTTP load tester can access the single randomizing URL over and over again, and fetch different records each time. This is a trivial load test script. In Jakarta JMeter, it is one of the samples.

This is really very easy to write inside of the server. Getting a random key looks something like this, assuming that we already have an instance of java.util.Random initialized and ready to go.

key = cache.keySet().get(random.nextInt(cache.keySet().size()))

In Python, you can use the default, shared instance of the random source and the choice() convenience method:

key = random.choice(cache.keys())

This can all be done in the code that parses the URL parameters. Once you have a random key, the remainder of the app executes with no changes.

If the app should be tested with a non-uniform distribution of accesses, that is also easy to do. Python’s random.paretovariate() looks especially good for Zipf (80/20 or “long tail”) distributions. Or you could duplicate that code in your favorite language:

def paretovariate(self, alpha):
"""Pareto distribution.  alpha is the shape parameter."""
# Jain, pg. 495
u = 1.0 - self.random()
return 1.0 / pow(u, 1.0/alpha)

For user logins, add an option to masquerade as a random user, or even a random user from certain classes (big profile, frequent login, new user …).

For testing search, I once made an especially fancy tester that would access a log of queries in order, but start at a different place for each client. This preserves the time locality of queries while giving each client a different set. I used a cookie to hold the per-client state, so that each client would access the queries in order from their starting place. It went roughly like this:

  1. If the client did not send a cookie, choose a random index in the log.
  2. Otherwise, read the cookie to get an index.
  3. Set the cookie to the next index.
  4. Wrap the index, modulo the log size.
  5. Run the search with the query at that index.

Now go test your software. I might need to use it someday.

While Reading Richard III

You’re expected to think deep thoughts while reading Hamlet, but Richard III is a crowd-pleaser, Shakespeare’s first big hit on the stage, so herewith a series of thoughtlets.

Shakespeare is famous for insults, but this play specializes in curses. There are a few good insults, of course. Richard calls Queen Margaret a “foul, wrinkled witch.” That sets the tone for that relationship. But the curses are almost as evil as the deeds, “Die neither mother, wife, nor England’s queen!,” Queen Margaret says, wishing the deaths of Queen Elizabeth’s father, sons, and husband.

Some of Shakespeare’s plays are more accessible than others. This one is pretty good, though keeping track of four kings, two queens, two near-queens (dead and promised, respectively), and innumerable lords gets a bit old. It would be easier to understand if Richard 3.0 directly followed Richard 2.0. But then we’d have betas. Dang.

Is it time for a new book of management ideology? The main challenge in writing Management Secrets of Richard III would be getting 300 pages out of “demand total loyalty, lie to everyone, kill anyone in your way.”

In Act 3, Scene 7 Richard makes a tremendously risky and confident move. Almost every obstacle between him and the throne is dead or locked away, so he refuses it and makes them beg. His false objections are a hint of truth, “Alas, why would you heap this care on me? / I am unfit for state and majesty.” When he finally agrees, he claims that the blame lies on them if it all goes wrong. Suckers.

The history of actors playing Richard seems to be a continuing struggle to rise above chewing the scenery. The part invites several kinds of overacting, but also allows very different interpretations. It must be a real thrill to nail that part.

Richard Plantagenet was born October 2, 1452, Niccolò Machiavelli on May 3, 1469. It is a shame that they never met. Niccolò had the theory, Richard the practice.

The play isn’t history, Richard couldn’t have been that evil. It is based on seriously biased Tudor histories. That makes it more fun, like listening to the home-town radio announcers for baseball instead of the carefully even-handed TV commentators. Before every Rice football game they’d tell us “No cheering in the pressbox,” but that didn’t stop us from writing how the dominant Owls crushed the hapless Horned Frogs.

I’m not especially happy with the notes in this edition (Signet), about a third of them are things I don’t need to be told, and there are quite a few mysteries without notes. I guess it is back to the Arden Shakespeare. More expensive, but worth it.

Many Shakespeare plays are just full of lines that are widely quoted. Beyond “this is the winter of our discontent” and “my kingdom for a horse,” there aren’t many in Richard III. Those two are the first line of the play and the last of the second to last act, Richard’s first and last lines — clearly Shakespeare knew when to play his best cards.

The pacing is interesting in Act 5. The last two scenes are extremely short, 13 and 40 lines to cover the final clash between Richard and Richmond, Richard’s death, and Richmond’s closing speech. If those were preceded by normal action, the play would feel cut short, unfinished. But the scene before delays the clash is a parade of ghosts who recapitulate Richard’s murders, something that would usually be done in a final speech. We are held at the high point of tension, and the shock of the final scenes can hit with full force.

These are not subtle or especially deep characters. Richard is broadly drawn, with some shreds of humanity, but the other characters are pretty shallow. Mostly, we get to watch them get sucked into the evil vortex that is Richard and see how much they struggle against it. They each get their turn, but it is all about Richard.

Update: A few hours after I posted this, I read about a Shakespeare-themed virtual world. The first play they’ll tackle is Richard III.

CALL BRTHDY(50)

FORTRAN turns 50 years old in four days. October 15, 1956 was the release date for Programmer’s Reference Manual, The FORTRAN Automatic Coding System for the IBM 704 EPDM (6.1 Meg scanned PDF). FORTRAN was an amazing achievement, inventing the idea of a compiler while generating code as fast as hand-coded assembler.

There are a couple of early papers that give a feeling for how hard all this was. The FORTRAN Automatic Coding System (1957) describes the design of the compiler. History of FORTRAN I, II, and III (1978) goes into the economics of computing at the time, influences, design decisions, and follow-ons. They didn’t have it really working until April 1957, which seems rather similar to modern software projects.

Some possible ways to commemorate this occasion:

  • RESTRICT YOUR TYPING TO 6-BIT BCD (SEE APPENDIX A OF MANUAL).
  • Use no words longer than six chars.
  • Propose the arithmetic IF as a Java extension.
  • Use GO TO. A lot.
  • Number your statements.
  • Refer to the LEDs on your computer as “sense lights”.
  • Solve a problem that uses only 32K 6-bit words of memory. Data and program has to fit.
  • No indentation.
  • Switch to vacuum tube heat this winter.
  • Write a program on a coding form, type it in, and run it. If there are any errors, even syntax errors, start over.

Prepare for the festivities by (re)reading the Programmer’s Reference Manual. It is only 51 pages, and refreshingly clear. The whole language fits in your head — no running back to the manual to figure out why const is propagating through your templates like a virus or whether you should use notify or notifyAll.

Goodbye, Liz

A dozen years ago, I heard one Liz Phair song on the radio and bought the CD. I’ve bought every one since. I heard the first song on her most recent CD, and I think this may be my last. I listened all the way through, but it was painful. By the end, I was making guesses about the next tired rock cliche, will she say “Baby” in this one? Yes.
As one Amazon reviewer said, “It is OK if she wants to be Sheryl Crow, but this isn’t even good Sheryl Crow.”

What the heck happened? Selling songs and making a living is good, but do they have to be so bland? Exile in Guyville is in the past, I don’t expect another one of those, but Somebody’s Miracle is just lame. Liz can write pop, I’m sure of it. “Polyester Bride” from whitechocolatespaceegg has a monster hook. The chorus will be stuck in my head for two days just from typing that sentence.

It’s been a fun ride, but I’m getting off now. Spread your wings and fly away, Liz.

My Preaching Schedule

I guess preaching is in my blood, like it or not.

I didn’t follow my father and grandfather into the ministry, but I recently realized that I have a regular preaching schedule. Twice a month, I deliver a “Scoutmaster Minute”, a traditional homily given at the end of a Boy Scout troop meeting. We gather in a circle, and I have a minute (or two or three) to say something meaningful and memorable.

My “parish” is this Scout troop, and the boys are in my care for a number of evenings and weekends each year, so I need to connect in those few minutes.

My father is an excellent preacher and a student of the art, so I’m not completely ignorant. Still, knowing and doing are separate things, and I’m still learning to practice what my father preached.

The ancient (and boring) formula is “tell ’em what you’re going to tell ’em, tell ’em, and tell ’em what you told ’em.” You might be able to get all that into a twenty minute sermon, but it is a bit much for a minute or three.

My father’s preferred approach, learned from Reuel Howe at the Institute of Advanced Pastoral Studies (how do I remember these details?), is more work, but more rewarding — take something from scripture, something from life, and relate the two.

Scouting doesn’t have Scripture, and Baden-Powell was a bit of a free-thinker and pacifist for the current crowd at BSA National, but I keep my eye out for authoritative bits of outdoor lore.

I also pay extra attention to my own life and my own memories. What have I done that is an example, good or bad? What matters this week for this troop?

Somehow, I picked up a few useful sermon-writing habits from my father — always carry a book, make notes, practice your stories and listen to other’s stories. Start with a rich pile of material (Gerry Weinberg’s fieldstone method), but also learn how to make a “good parts version” of that material. A great storyteller can spin a long yarn (Utah Phillips’ “Moose Turd Pie”) but I’m more comfortable with short and sweet.

I’ve started posting my Scoutmaster Minutes; the first two are Steve Irwin and Take the Bruised Apple.

These look very short when written down, but the second one is about a minute and a half when spoken, and felt pretty long in the meeting. Steve Irwin comes in right around thirty seconds and was very effective. I find this an interesting thing to get better at.

I haven’t had a problem finding a core, some quote or experience, but my first few minutes just petered out at the end. The two that are posted are after I started working on the close. What should I work on next?

Movable Type’s Impenetrable CSS

I really like MT, but the 3.x layout is really, really hard to work with. With MT 2.6, I spent about 45 minutes and had a simple fluid layout. Done. With 3.0, I wasted a couple of hours and got nowhere. I’ve seen a couple posts where people spent six or eight hours to get it working. That’s crazy.

I really, really hate fixed-width designs and Six Apart doesn’t offer a single fluid design in their styles, so I’m forced to do it all from scratch. A fixed-width design is like a guest walking into your home and immediately rearranging all the furniture to suit them. It is total design arrogance and I won’t do it.

The current layout is my old 2.6 templates pasted onto 3.x.

So, if parts of this blog are ugly, like the comments popup, well, it is my responsibility, but I just don’t have a full day to sacrifice to the CSS god and the ridiculous design from Six Apart. Sorry about that. It is on my list of things to fix.

Google Blog Search Catches Up, Sort Of

Google Blog Search adds support for blog ping only two years after it shipped in Ultraseek (in version 5.3, September 2004). Want to bet the Google Appliance still doesn’t have it?

It wasn’t hard to implement, either. I put it together for Ultraseek in a couple of days. Clearly, most of their people are working on ads, not search. After all, ads make money and search costs money.