5 Load Testing Scenarios for Your API

When load testing an API, you need to use different load conditions to see how the API handles them. Here are some questions that your load tests should answer:

  • What number of users can work with the API at the same time?
  • How long can users work with the API before the restart is needed?
  • What if a high number of users are working with the API for an extended period?
  • What happens if a sudden spike of users that the API cannot handle happens?

Below is an introduction to five different scenarios you can test:

 

Baseline testing

You can use this load testing strategy to get a basis for your further load tests, or to assess how your API performs against service-level agreement (SLA).

Your test should help you determine what response is normal for the API. You can then use these values to set up the assertion in other tests. You may also find API or target TestCase problems that would prevent longer load tests from running correctly. This is also a good way to check if your API performs according to SLA.

To estimate the API performance, add assertions and API monitors that will check the response time, the size of transferred data and other values to which your SLA can refer.

 

Screen-Shot-2018-06-06-at-9-27-22-AM.png

Stress Testing

Stress testing means simulating heavy load on the API to find the maximum number of users the API can handle. This number is also called a crash point

The crash point does not necessarily mean that API crashes or hangs. It can mean that errors start happening or that the API performance or response time fall below the level that your service-level agreement (SLA) defines.

You’ll need to create assertions and API monitors to check the API response against the limits specified in your SLA. When the responses take longer than the SLA specifies, your API runs out of processing power, or errors start happening - you have reached the maximum capacity of your API.

 

 

Soak Testing

You use soak testing to find issues that come up during extended work with the API, like API memory leaks.

Ideally, at the end of the test run, the API performance should be the same performance as at the beginning of the test. The decrease in performance can indicate that the API code has some issues.

Test Parameters

To create a soak test:

  • Use the Fixed, Variance load profile or a combination of both.
  • Configure the profile settings to simulate a load that is slightly above expected average load.
  • Set a very long test duration. Ideally, soak tests should run for more than a day
  • Create assertions and API monitors that will help you evaluate the API performance.

 

Peak Testing

Use peak testing to check how your API works during the busiest periods. Peak testing is similar to soak testing, but with much heavier load and shorter duration.

To create a peak test:

 

  • Use the Ramp Sequence or Variance load profile. You can also run a test with the Fixed load profile in parallel to simulate background load.
  • Simulate the load that is close to the maximum expected load on the API, while providing some breathing space.
  • Set a long test duration, for example, half a day
  • Create assertions and API monitors that will help you evaluate the API performance.

 

Spike Testing

Spike testing helps you check how the tested API responds to a sudden spike in the number of users. The API should be able to stabilize and return to normal functioning after the spike passes.

To create a spike test, use the Burst load profile. It helps you simulate a short burst of users well above the expected maximum load. After Screen-Shot-2018-06-06-at-9-28-42-AM.pngthat or in parallel, run another load test to check how the API handled the spike.

If you simulate the Burst load profile with the Rate load type, the test will create a large number of virtual users coming to the API. This will simulate the sudden spike that can easily overwhelm the API. If you simulate the Burst load profile with the VUs load type, you can specify the exact top number of users that will work with the API. The test will simulate the specified number of users, even if API responses slow down.

 

Performance Testing Requires the Right Set of Tools

As you can see, there are a number of tests you can run to ensure the performance of your API. While load testing is essential, your performance strategy should extend throughout the lifecycle of your API. Luckily, with a tool like Ready API, you can reuse functional tests to set up monitors for API once it’s in production. 

ReadyAPI combines the power of SoapUI ProLoadUI ProServiceV, and API Monitoring in AlertSite into a single application. From functional testing, to performance testing to post-deployment monitoring, SmartBear’s API tools help you to deliver accurate, fast, and secure APIs.

Start Your Free Trial Today

 

Learn More: