Create Load Tests in Node.js Using Autocannon

Will Mendes
InstructorWill Mendes
Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 3 years ago

Tests are really important in the software development cycle. But how we can test if our API - or even a page - will support the web traffic and requests our users will create by accessing them?

In this video, you will learn how to create HTTP load and benchmarking tests in Node.js using the autocannon package. With that, we can make sure our API is not consuming too much memory, CPU, or any other resource that can cause slow responses.

Instructor: [0:01] We need to clone our repo called micro-frontend pages. We go, click at the link, and moving back to our terminal, we can run Git-Clone, pass in the link that we copied. Inside the folder, we can run docker-compose, and space up --viewed.

[0:20] We can run all docker configuration that we have for all the pages in the repo, and view their images. Now that we have this adapt finished, let's route to cannon. We'll be routing to cannon and configuring to simulate 100 connections for 30 seconds, with time per manual requests, bypassing 100 on Dash-C, 30 on Dash-D, and 10 on Dash-B.

[0:48] As a last parameter, we can pass the website for a round of tests. Now pointed to local host, 8888 is the port and /docs, and that will be pinging our page. When you click enter, it will be running and show the loader for the task. When it finishes, it shows all the information for that specific task.

[1:12] As you can see, autocannon will show you all the information for latency, request per second, and bytes per second. Those information are really relevant and really important for application if you want to work in performance or even improve those numbers.

[1:31] As a recap, we are running autocannon using NEPX in configuring to simulate 100 connections for 30 seconds using 10 pipelines. The last parameter we'll be passing will be the address we want to check, which is localhost 8888 is the port \docs.

egghead
egghead
~ 13 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today