Automated Load Testing

My previous post covered finding a random point within a bounds, which worked great for testing random locations throughout the country for an app. Then we realized that we did not have a way to reliably load test our API endpoint with random locations.

After some googling and some scripting, I ended up with something that worked pretty well.

There are a couple of requirements we need to meet:

  1. Make it throttle-able
  2. Make it trackable
  3. Make it random

In the past I’ve used Apache load balancer, but unfortunately this won’t work for us because 1) we’re going to be doing a POST request and 2) the data is going to be random.

Several Google searches into this, I came across this gist which seemed to be a good starting point. It was throttle-able, had useful output built in for tracking how our test was going, and it was using CURL for the request which should make for an easy conversion to a POST request.

I’ll save the hour of trial/error to get it working with my requirements, and just post the final script:

This will execute a PHP script (similar to the script we created in the previous post which I will post below) which outputs a CURL command X number of times per second, and outputs the result into a log file. This works by spawning our script each time in a new thread. Run it with:

The output will look something like:

Here is our slightly modified PHP file. This adds a new function to create a CURL string and then echo it.

Leave a Reply

Your email address will not be published. Required fields are marked *