API load testing

API load testing from simple API hammering to complex API user scenarios.

API performance challenges

Anticipating how resources will be manipulated as well as retrieved via an API requires skillful planning. API performance is affected by server availability, response times, network latency and throughput. Each of these require a different level of optimization work if found to be the source of poor performance. The Load Impact cloud service and the open source load testing tool it's built on (k6) are aimed at helping you proactively test API performance. As the rate of code deployments increase with DevOps and automation, test your APIs from early dev stages to end-to-end tests in pre-production environments.

With our solution

hero-macbook-api-load-test-results-next-gen.png

Application availability

Guarantee that resources exposed by your API can be Created, Read, Updated and Deleted appropriately under expected, as well as unexpected, load.

Scalability

Validate application and infrastructure scalability and measure end user performance.

SLAs

Ensure the response times experienced by your API users are acceptable and within the boundaries of Service Level Agreements (SLAs).

Trending

Establish a long-term baseline for your API performance on which to validate the impact (good and bad) of code and infrastructure changes over time. Read more about performance trending.

 

Failure cases

Determine your maximum capacity, through stress testing, in order to understand which components fail first, in what order and what the nature of that failure is.

 

 

Test Your API - Start a Free Trial

Powerful API scripting features

Scripting in ES6 JavaScript

Write your API performance tests in familiar and powerful ES6 JavaScript. No need to invest time learning yet another language or an old-school clunky GUI tool to do your performance testing.

ES6 modules

With ES6 modules support builtin, it's easy to modularize your scripting logic for reuse across tests and team members. You can even use some existing Node.js modules via Browserify.

Checks and Thresholds

Use checks (like asserts) to make sure your tests are functionally correct, and setup test pass/fail criteria using thresholds to open up the door for automated load testing with CI/CD tools and services.

HTTP/1.1, HTTP/2 and WebSocket

Test your full set of APIs with both HTTP and WebSocket support builtin, or see what speed ups you can achieve by switching to HTTP/2.

Full CRUD support

Send requests with any of the HTTP methods/verbs. GET, POST, PUT, DELETE, PATCH and OPTION, they are all supported.

Custom metrics

Use custom metrics to capture the data that matters to you, with support for Counter, Gauge, Rate and Trend types of metrics.

 

 

For more information see our scripting introduction and the k6 documentation.

 

script.js

import { group, sleep, check } from "k6";
import http from "k6/http";
import {Trend} from "k6/metrics";

// Create a custom metric to track latency and get login credentials from env vars
let latencyMetric = new Trend("latency");
let email = __ENV.EMAIL;
let password = __ENV.PASSWORD;

export let options = {
    thresholds: { "http_req_duration": [{ threshold: "p(95)<500", abortOnFail: true }] }
};

export default function() {
    // Login to get API session token
    let res = http.post("https://api.loadimpact.com/v3/account/login",
        JSON.stringify({ email: email, password: password }),
        { headers: { "Content-Type": "application/json" } }
    );

    // Add custom metric data point and tag it with the endpoint (for graphing purposes)
    latencyMetric.add(res.timings.waiting, {endpoint: "account/login"});
    sleep(1);

    // Extract API session token from JSON response
    let resJson = res.json();  // res.json() is cached between calls
    let apiToken = resJson.token.key;

    // Use session token to make API requests
    res = http.get("https://api.loadimpact.com/v3/account/me",
        { headers: { "Authorization": "Token " + apiToken } }
    );
    check(res, {
        "status is 200": (res) => res.status === 200,
        "content OK": (res) => JSON.parse(res.body).hasOwnProperty('organizations')
    });
    latencyMetric.add(res.timings.waiting, {endpoint: "account/me"});
    sleep(3);
}

Already using Postman?

Use Load Impact's conversion tool for Postman to load test your Postman API collections

Automated load testing

Three essentials for automated performance testing

Goal oriented

We believe load testing should be goal-oriented and want to make it as easy as possible for you to achieve that. By setting up thresholds, as pass/fail criteria, in your script your tests will be automatically failed when those thresholds are overrun.

Execution options

We also believe in the practice of continuous performance testing. Load Impact is built on top of our open source load testing tool k6, and with the ability to run tests both from local/on-premise or using our cloud service makes it easy to integrate load testing with your CI tool/service of choice.

Notifications

To stay completely out of your way, when your tests finish, we can notify you in Slack, HipChat or via Webhook. Be the first to know if your tests fail!

Check out our CI integration guides