Developer focused load testing for your API.

Load testing your API is made easy by LoadForge. We have built in tools to generate load tests, easily scriptable and customizable test files and even support custom python scripting.

Prefer to just sign up? Loda test your API in ~5 minutes.

REST, GraphQL, XMLRPC, And More

Testing your API

Testing a modern REST API is very similar to testing a web application. You want to ensure that all the dependencies of the system are put under load as well - the "heaviest" workloads. By examples these can include:

  1. Authentication and user (or token) management
  2. CRUD operations, especially Updates or Creates
  3. High speed read operations
  4. Caching and various optimization layers

These operations are interactive, dynamic content. Typically they all require backend processing, and often require a SQL database interaction or cache.

To aid in your testing we have specific example scripts for API load testing available:

We also provide assistance in test scripting should you need. Register a free account now and run your first load testing in minutes.

LoadForge allows API load tests up to 50 simulatanous users for free.


Detailed Guide

Read our full API load testing step-by-step guide below. We're available to assist on live chat or by contacting us whenever you need.

API Operations

API operations are interactive, dynamic content - and often POST requests. They typically are generated by a language like PHP, and often require a SQL database interaction. These are the common bottlenecks in a modern web application. Server load testing is very different, and has to do with raw requests per second from the web server itself, e.g. Nginx, Apache, etc. You should make sure that your web server is also capable of delivering high requests per second, which can easily be tested with LoadForge.

LoadForge has examples, wizards and browser recording to make load testing easier. Advanced users can script tests however they like.

Breaking Your API Into Components

We want to split load testing for APIs into the three categories above, and potentially more depending on the size and load profile of your API. For example, you might know your API handles very few write operations but a large number of read operations. Another example comparison would be do you have API clients that are sending a large number of requests, or, a large number of clients with fewer requests.

For this example, we'll define our API like this:

  • High volume of dynamic read operations
  • Low volume of write operations
  • Large number of different users

We're going to initially read two test variables from that. Firstly, we'll set our wait time on each individual API user to 1 request per 1-3 seconds. Secondly, we'll set our number of connected API clients (users) to 5000 initially.

The last piece of information from our tasks is that we know we are going to get far more read operations, so we'll plan for around 10x as many reads per client as there are writes.

api-create.png

As you can see above, we have set up the basic layout of our test. The next step will be to define the actual test locustfile - the script that is going to generate our requests to our API.

Creating a the locustfile

We can now write our LoadForge test, which we will execute against our website we've defined above. We'll start by defining just the basics - the website to run it against, and that we'll start with 5000 simultaneous users. Remember that with our 1-3 seconds wait time decision that will be a large number of users.

import random
from locust import HttpUser, task, between

class QuickstartUser(HttpUser):
    wait_time = between(1, 3)

    def get_results(self):
        self.results = []

        # Fetch all the results and store their IDs for later
        response = self.client.get("/api/results")
        for result in response.json():
            self.results.append(result['id'])


    def on_start(self):
        # Spread out starts
        self.wait()

        # Set out Bearer auth token
        self.client.headers.update({'Authorization': 'Bearer TOKEN_HERE'})

        # Load up all the possible results
        self.get_results()


    @task(1)
    def read_hosts(self):
        self.client.get("/api/hosts")

    @task(2)
    def read_tests(self):
        self.client.get("/api/tests")

    @task(5)
    def read_results(self):
        # Select a random result from the get_results query to fetch
        self.client.get("/api/result/" + str(random.choice(self.results)))

    @task(1)
    def crud_host(self):
        # Make a new Host and get the json reply
        response = self.client.post("/api/hosts/create", {'url': 'www.test.com', 'port': '443', 'protocol': 'https'})
        host = response.json()

        # Delete what we just made
        self.client.post("/api/hosts/delete", {"host_id": host['host_id']})

Lets break this down, it's quite similar to our default template, and if you want advanced uses check out our examples directory.

We've defined a low wait time as discussed. Then we've got two read tasks that run, a read results tasks that runs 5x more than default (@task(5)) and a crud_host test to create and delete a host.

You'll notice in the on_start section we do two critical things:

  1. Set the bearer token for the API (fill that in)
  2. Run get_results to get a list of all possible results from the API, to use in read_results()

Over time you'll build a far broader API test, testing each function and being able to profile the performance of each request. That's right: LoadForge will show you the response time and RPS for each item defined in your test, helping to find slow queries!


Understanding Results

Interpreting the results of your test are as important as running the test, if not more. Continue this on our reading load test results guide.


More Examples

We have loads of locustfile examples available in our free Examples Directory.


Beautiful, powerful reports, with actionable metrics

LoadForge automatically analyzes your site, explaining errors, showing detailed graphs, and performance numbers per page.

  • Graphs for requests, errors, rates, latency, P95, P99
  • HTTP error analysis and performance AI
  • Download CSV or PDF reports
  • Store and compare your tests