Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

When developing API, you will have some APIs that need to perform at their very best.

With API Statistics built in and a mass API test tool you can discover potential bottlenecks within your business logic, database indexes, and even Application Infrastructure.

Performance testing is very similar to manual testing, with a key difference of using a tool to call your API in mass and under difference scenarios.

Load testing and stress testing are other types of tests you perform to find the benchmarks of your Application Infrastructure.

I recommend a tool called Artillery.  It 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:

  • npm install -g artillery

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 a for 60 seconds, 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: 

  1. Navigate to the Profound.js IDE
  2. Open the API file 
  3. 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.

On the top right hand corner of this tab, there are refresh buttons, refresh now, auto-refresh paused, auto-refresh every 1 second, 10 seconds, 30 seconds and every minute.

These statistics are being 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 more important information:

  • Request - This is the total requests
  • Errors - This is the total errors
  • Average Handle Time - Average time the server took to respond to each request over the last hour
  • Handle Time histogram - This will show how this API has been responding over the last hour
  • Overall Req rate - This number can be misunderstood.  The calculation is based on the start of the Profound.js service
  • Overall Err rate - This number can be misunderstood. The calculation is based on the start of the Profound.js service

  • No labels