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.
Fig.1 - Export Requests Collection
Afer this step, we should receive a JON file contains all the information of the REST APIs we would like to test.
Step.2 Write Code for Load Testing
We need to create a sepearte xxx.js file that tells AutoCannon what to do.
Then we should able to see output like this for each invidual request:
Fig.2 - API1 resultFig.3 - API2 result
For sure, there are more details left to discover, e.g. settings of _autocannon_, but that is left for reading and searching the official document :)