A Novice’s experience with Load Testing using Autocannon

A Novice’s experience with Load Testing using Autocannon

Puppeteer?is one of the most common libraries used for generating pdfs. In general, the steps involved are for every pdf generation request:

  • launch the puppeteer process
  • connect to the process
  • generate the pdf
  • disconnect from the process
  • close the process

We wanted to skip the launching and closing part for every request by opting for a dedicated puppeteer server and keeping it up and running. Then, connect to that server and generate pdf and disconnect.

Now, we wanted to observe the load it could handle and understand how CPU and memory usage grow with the increase in load. For this, we decided to do a load test. There are many tools for load testing like Artillery, JMeter, Autocannon etc. We chose to use?Autocannon?for load testing.

Server load testing and benchmarking are essential to understand how many requests a server can fulfil successfully at the same time.

Autocannon is a?HTTP/1.1 benchmarking tool written in Nodejs.?It also supports?HTTP pipelining.

Installation

No alt text provided for this image

Load Test Your Sever

We can run it directly from command line

No alt text provided for this image

we can also run it programmatically. Here is a sample code you can use for your reference.

No alt text provided for this image

In the above code snippet, a post request is being sent. We can add connections and the duration(the time it will execute) according to our requirements. By default, 10 concurrent connections are made, executing for 10 sec. The requests is an array of requests e.g.,

No alt text provided for this image

After the execution, the output looks like below:

No alt text provided for this image

Here are the meanings of the few terms that we see in the result-:

  • url: The URL that was targeted.
  • socketPath: The UNIX Domain Socket or Windows Named Pipe that was targeted, or undefined.
  • requests: A histogram object containing statistics about the number of requests that were sent per second.
  • latency: A histogram object containing statistics about response latency.
  • throughput: A histogram object containing statistics about the response data throughput per second.
  • duration: The amount of time the test took in seconds.
  • errors: The number of connection errors (including timeouts) that occurred.
  • timeouts: The number of connection timeouts that occurred.
  • mismatches: The number of requests with a mismatched body.
  • non2xx: The number of non-2xx response status codes received.
  • resets: How many times the requests pipeline was reset due to setupRequest returning a false value.
  • average: The average (mean) value.
  • p*: The XXth percentile value for this statistic. The percentile properties are: p2_5, p50, p75, p90, p97_5, p99, p99_9, p99_99, p99_999.

For a detailed reference, read —?Autocannon. These data help in evaluating the performance of the application.

Limitations

  • CPU Bound and can saturate the cpu sooner than other tools. It uses significantly more CPU than other tools that compiles to a binary such as?wrk.

Conclusion

Load testing is essential in the Software Development Lifecycle. It not only evaluates how the performance of an application can be affected by average and peak loads but also simulates real user scenarios. Therefore, load testing should be a part of the strategy to make software applications more efficient, effective, performance-oriented, and consumer-driven.

? Thank you for reading and I hope you find it helpful. I sincerely request your feedback in the comment’s section.

- Princy Gupta (Tech team, Powerplay)

要查看或添加评论,请登录

Powerplay的更多文章

社区洞察

其他会员也浏览了