blitz.io: Load testing location-aware iPhone, Android apps

Location awareness is the hottest thing in town and most mobile apps on the iPhone and Android are adding this capability to find friends, restaurants, movies and other things within a certain proximity of where you are. If you are rolling out a new location-aware iPhone or Android app or you want to load test your existing location-aware app, this blog is for you. With the launch of blitz.io, we are making location-aware load testing as easy and fun as it gets.

Geo-spacial Queries

I’m sure you’ve seen pictures similar to this:

photo.png

When this app loads, it’s using the built-in GPS to first find the location and then transmits that information to the backend server. The latitude and the longitude are then used to run geospacial queries on the database to find certain elements that fit within the bounding-or radius around the specified point. This could be friends, cinemas, restaurants, etc.

Most databases already support this in some capacity. Question is how do you run a load test that involves hundreds of thousands of users using your app from various locations around the world. Until last week, blitz.io only supported load testing of a single unparameterized URL. While this was quick and dirty because we wanted to get blitz out, it doesn’t quite cause the same kinds of stress on the server.

The RESTful URL

Let’s say this hypothetical app makes this call to the backend server:

http://my.cool.app/locate.php?latitude=37&longitude=-122&radius=1

Looks fairly straight forward. We pass in the location and get back a JSON or XML response. What we need is the ability to parameterize the query arguments so that we can load up the backend server with users from all over the world.

Data-Driven Testing

As I mentioned in my last blog, blitz.io uses the same engine as Studio Scale. So while the underlying engine supported full parameterization, we wanted to adapt this to the cURL-ish feel of blitz. So here’s what we are planning on rolling out.

Step #1 – Define a variable

For clarity, we’ve broken up the single cURL-ish line, but you enter this whole thing without the line-breaks into the blitz bar. Okay, first we are going to define two variables, lat and long with the appropriate desired ranges.

-v:lat number[37,59]
-v:long number[-127,-122] 

http://my.cool.app/locate.php?latitude=37&longitude=-122&radius=1

Step #2 – Use the variable

At this point, the scale engines generate the required data sets, but we are not actively using them anywhere. So let’s try rewriting the URL to use these variables:

-v:lat number[37,59]
-v:long number[-127,-122] 

http://my.cool.app/locate.php?latitude=#{lat}&longitude=#{long}&radius=1

Step #3 – Define the radius

Having every concurrent user in a load test use the exact same radius is kinda contrived. Most people are going to be panning and zooming around. So let’s make radius a variable and use it.

-v:lat number[37,59]
-v:long number[-127,-122]
-v:radius [1,2,3]

http://my.cool.app/locate.php?latitude=#{lat}&longitude=#{long}&radius=#{radius}

Step #4 – Crank it up!

Blitz automatically chooses a worldwide region for you. But let’s say we wanted to load up your server from california. As easy as it gets:

-r california
-p 1-1000:60
-v:lat number[37,59]
-v:long number[-127,-122]
-v:radius [1,2,3]

http://my.cool.app/locate.php?latitude=#{lat}&longitude=#{long}&radius=#{radius}

This generates upto 1000 concurrent users from california in 60 seconds with the requests fully parameterized! Simple, concise and makes a great one-liner. Here’s the graph that you get:

But, my app uses JSON POST requests!

Not a problem. Here’s what you do:

-v:lat number[37,59]
-v:long number[-127,-122]
-v:radius [1,2,3]
-X POST
-d '{"latitude":#{lat},"longitude":#{long},"radius":#{radius}'

http://my.cool.app/locate.php

See, simple?

Can I parameterize request headers too?

Why not? Go for it. You can use variables in any part of the request and more than once, if you want.

-v:lat number[37,59]
-v:long number[-127,-122]
-v:radius [1,2,3]
-H 'X-Latitude: #{lat}'
-H 'X-Longitude: #{long}'
-H 'X-Radius: #{radius}'

http://my.cool.app/locate.php

Awesome, When I can get this?

We are planning on making this live in the next few days. Check it out:

blitz.io: Making load and performance testing a fun sport!

Bookmark and Share