Loading Testing and Benchmark A Set of REST APIs using AutoCannon
Recently, I need to do load tests for a set of REST APIs under Node.js environment. After studying some online articles, I decided to give it a go with AutoCannon. My scenario is that I have already had a sets of requests setup in Postman, and I do not want to rewrite everything for the load test. Luckily, I found a solution that exactly match my requirement (listed below), but I still want to write my own version from a AutoCannon fresher’s perspective and hopefully will be useful for future readers.
Step.1 Export A Collection of Requests from Postman
As shown below, left click the “…” button at the right side of the requests collection. Then choose “Export” in the popup menu.

Step.2 Write Code for Load Testing
We need to create a sepearte xxx.js file that tells AutoCannon what to do.
- Load request data from exported JSON file
1 | const autocannon = require('autocannon'); |
- Set up AutoCannon for Each Request
1 | entries.map(async (entry) => { |
Launch the test
In the terminal window, run the following
1 | node xxx.js |
Then we should able to see output like this for each invidual request:


reference
Benchmark express apis with autocannon from postman collection