Some APIs that you develop will have strict performance requirements.
With integrated API Statistics and a mass API test tool you can discover potential bottlenecks within your business logic, database indexes, and even application infrastructure.
Performance testing is similar to manual testing, with a key difference of using a tool to call your API in mass and under different scenarios.
Load testing and stress testing are other types of tests you can perform to find the benchmarks of your application infrastructure.
A useful tool for stress testing and determining benchmarks is Artillery, which allows mass calling of your APIs along with configurable scenarios.
Artillery is a free node package that you install on your local computer like this:
It can be used in a variety ways. Here are a couple quick ways to use it from a terminal:
This will start 20 connections (sessions), and on each connection it will call your API 100 times, 1 at a time.
This is a good example for performance testing, and can tell you the overall throughput of your API
This will run for for 60 seconds, and each second 20 API calls are attempted
This is good example for load or stress testing and can tell you how well this API will stand up under pressure.
The Artillery output provides metrics on these tests, which include:
Scenarios launched and completed
Response times in different forms: min, max, mean, median, top 95 and 99 percentiles
Response status codes
With the mass tests running or finished, you can take a look at the API statistics:
Navigate to the Profound.js IDE
Open the API file
At the bottom right, change to the Stats tab
To view all of your API globally, you can use the API Dashboard, it includes all of this plus much more.
At the top-right corner of this tab, there are refresh buttons. They allow you to refresh now, pause auto-refresh, auto-refresh every 1 second, 10 seconds, 30 seconds and every minute.
These statistics are collected automatically through the Profound.js service.
Below is an example of API file customer.api.json file, with the Get one customers API selected.
From this test view, you can see a lot of information. Some of the interesting statistics include:
Requests - Total number of requests
Errors - Total number of errors
Average Handle Time - Average time the server took to respond to each request over the last hour
Handle Time Histogram - A graph showing how this API has been responding over the last hour
Overall Req rate - Requests per second since the start of the Profound.js service
Overall Err rate - Errors per second since the start of the Profound.js service