AWS Builder Center
Load Testing a REST API with Distributed Load Testing on AWS: A JMeter Tutorial

Load Testing a REST API with Distributed Load Testing on AWS: A JMeter Tutorial

Follow this Distributed Load Testing on AWS JMeter tutorial to deploy the CloudFormation stack, run a REST API load test, and read p99 latency results.

Full Stack Developer @Salesforce @MuleSoft | Building JMeter.AI | IAmSpeed.dev | ai.dosa.dev
In this blog post, we will see how to run a Distributed Load Testing on AWS JMeter tutorial end to end, from deploying the solution to reading the p99 latency numbers for a REST API test.
I have spent most of my performance engineering career babysitting JMeter controllers and load generator boxes on EC2, so when I first deployed this solution I kept waiting for the part where I had to SSH into something. It never came. That alone made it worth a closer look.

What is Distributed Load Testing on AWS

Distributed Load Testing on AWS is an open source AWS Solutions Implementation. You deploy it into your own account with a CloudFormation template, and it gives you a web console for creating, scheduling, and running load tests.
The part I like is the test framework support. It is not locked into one tool. You can bring a JMeter test plan, a k6 script, a Locust script, or just point it at a plain HTTP endpoint with no script at all.

Why it is worth a look

If you have ever run JMeter at scale, you know the annoying part is rarely the test plan. It is standing up enough load generators, coordinating them, and tearing them all down afterward without leaving a pile of forgotten EC2 instances running up your bill.
Distributed Load Testing on AWS hands that whole problem to Fargate. You describe how many concurrent users and how long, and it launches however many containers it needs to hit that number, across one or more Regions if you want geographically distributed traffic.
A few things stood out to me as genuinely useful rather than just marketing checkboxes:
  1. No servers to patch or size. The containers come and go with the test.
  1. Multi-Region tests for checking how your API behaves for users hitting it from different parts of the world.
  1. Built-in baseline comparison, so you can flag a test run as your baseline and see later runs measured against it.
  1. Scheduling, including cron style recurring tests, which is handy for a nightly regression check.

How it works under the hood

At a high level, a web console sits in front of an API Gateway and a set of Lambda functions that manage test data and orchestration. When you kick off a test, the workflow hands off to Fargate tasks running on an Amazon Linux based container image, each one generating load against your target. Results land in DynamoDB and get surfaced back in the console as metrics and percentiles.
You do not need to memorize this to use the tool, but it explains why there is nothing left running after a test finishes. Once the tasks complete, the containers are gone.

Setting it up

Head to the  Distributed Load Testing on AWS solution page  and grab the CloudFormation template linked there.
  1. Launch the CloudFormation stack in the Region you want your load generators to run from.
  1. Fill in the parameters, mainly an admin email address, since the solution creates a Cognito user for you and emails you a temporary password.
  1. Wait for the stack to finish. Deployment is quick, well under half an hour in my experience.
  1. Grab the console URL from the stack's Outputs tab.
as shown below
Log in with the temporary password, set a new one, and you are looking at the test console.

Our example: load testing a products API

To keep this concrete, let's say you have a simple  /products  REST endpoint backing a storefront, something like  https://api.example.com/products , returning a paginated product list as JSON. We want to know how it holds up at 200 concurrent users for 5 minutes, and we already have a JMeter test plan ( products-api-test.jmx ) that hits this endpoint with realistic think time between requests.
This is the same example we will use for every step below, so swap in your own endpoint and  .jmx  file when you follow along.

Creating and running the test

  1. From the console, click Create Test.
  1. Give it a name, something like  products-api-baseline .
  1. Choose JMeter as the test type and upload  products-api-test.jmx .
  1. Set concurrency to 200 and duration to 5 minutes.
  1. Leave it as a single Region run for now, we can add more Regions later once we have a baseline.
  1. Click Run Test.
As shown below, the console gives you a live view while the test is running, including virtual user count and response times updating in near real time.
Once it wraps up, mark this run as your baseline. Every future run against  /products  can now be compared against it directly in the console instead of you eyeballing two dashboards side by side.

Reading the results

Once the test finishes, the results page gives you the numbers that actually matter for a decision:
  • p50, p90, p95, p99 response times, so you can see the tail, not just the average
  • Error rate, broken out by response code
  • Throughput, in requests per second, over the duration of the test
  • Downloadable artifacts if you want to pull the raw data into your own analysis
For our  /products  example, this is where you would notice something like a healthy p50 around 120ms but a p99 that jumps to 900ms, which is usually your first clue that something, maybe a downstream database query or a cold Lambda, is the actual bottleneck under load rather than the API layer itself.
If your first instinct is to size everything off the average response time, this is exactly the kind of gap that bites you later. I have made that mistake before on a much bigger test, and the p99 is always the number that catches you off guard in production.

Where this fits in your pipeline

Because the whole thing is driven by an API behind API Gateway, you are not limited to clicking around the console by hand. You can trigger tests from a CI pipeline, gate a deployment on error rate or p99 thresholds, and use the scheduling feature for a recurring nightly regression run against a staging environment.
For teams already running JMeter or k6 scripts locally, this is a fairly low friction way to move the same scripts into a proper distributed setup without owning the infrastructure that runs them.

Closing thoughts

If you already have JMeter, k6, or Locust scripts sitting around and have been putting off setting up proper distributed load generation, this solution removes most of the excuses. No servers to size, multi-Region support out of the box, and baseline comparison built in.
Give it a shot on an endpoint you actually care about, not just a demo API, and see what your p99 tells you.
Happy Testing!
Have you tried Distributed Load Testing on AWS already, and if so, what did you test it against?
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article