Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

autocannon

Package Overview
Dependencies
Maintainers
3
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autocannon

Fast HTTP benchmarking tool written in Node.js

  • 7.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
59K
decreased by-54.25%
Maintainers
3
Weekly downloads
 
Created

What is autocannon?

Autocannon is a fast HTTP/1.1 benchmarking tool written in Node.js. It is designed to be easy to use and provides a way to quickly and effectively benchmark HTTP servers. It can be used to simulate a large number of requests to a server, measure the performance, and identify bottlenecks.

What are autocannon's main functionalities?

Basic HTTP Benchmarking

This feature allows you to perform a basic HTTP benchmarking test on a specified URL. The code sample demonstrates how to benchmark a local server running on port 3000 with 10 connections for a duration of 10 seconds.

const autocannon = require('autocannon');

const run = autocannon({
  url: 'http://localhost:3000',
  connections: 10, // default
  duration: 10 // default
}, console.log);

process.once('SIGINT', () => {
  run.stop(); // this will stop the benchmark
});

Custom HTTP Headers

This feature allows you to include custom HTTP headers in your benchmarking requests. The code sample demonstrates how to add an 'Authorization' header to the requests.

const autocannon = require('autocannon');

const run = autocannon({
  url: 'http://localhost:3000',
  headers: {
    'Authorization': 'Bearer token'
  },
  connections: 10,
  duration: 10
}, console.log);

process.once('SIGINT', () => {
  run.stop();
});

POST Requests

This feature allows you to perform POST requests during the benchmarking test. The code sample demonstrates how to send a JSON payload in the body of the POST requests.

const autocannon = require('autocannon');

const run = autocannon({
  url: 'http://localhost:3000',
  method: 'POST',
  body: JSON.stringify({ key: 'value' }),
  headers: {
    'Content-Type': 'application/json'
  },
  connections: 10,
  duration: 10
}, console.log);

process.once('SIGINT', () => {
  run.stop();
});

Multiple Requests

This feature allows you to define multiple types of requests to be sent during the benchmarking test. The code sample demonstrates how to send both GET and POST requests to different paths.

const autocannon = require('autocannon');

const run = autocannon({
  url: 'http://localhost:3000',
  requests: [
    { method: 'GET', path: '/' },
    { method: 'POST', path: '/data', body: JSON.stringify({ key: 'value' }), headers: { 'Content-Type': 'application/json' } }
  ],
  connections: 10,
  duration: 10
}, console.log);

process.once('SIGINT', () => {
  run.stop();
});

Other packages similar to autocannon

Keywords

FAQs

Package last updated on 08 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc