All Projects → matteofigus → Api Benchmark

matteofigus / Api Benchmark

Licence: mit
A node.js tool to benchmark APIs

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Api Benchmark

Meta Blocks
A modular toolbox for meta-learning research with a focus on speed and reproducibility.
Stars: ✭ 110 (-62.46%)
Mutual labels:  api, benchmark
Yahooquery
Python wrapper for an unofficial Yahoo Finance API
Stars: ✭ 288 (-1.71%)
Mutual labels:  api
Insomnia
The open-source, cross-platform API client for GraphQL, REST, and gRPC.
Stars: ✭ 18,969 (+6374.06%)
Mutual labels:  api
Pfsense fauxapi
REST based API interface for pfSense 2.3.x and 2.4.x to facilitate devops
Stars: ✭ 288 (-1.71%)
Mutual labels:  api
Docma
A powerful tool to easily generate beautiful HTML documentation from JavaScript (JSDoc), Markdown and HTML files.
Stars: ✭ 287 (-2.05%)
Mutual labels:  api
Express Graphql Mongodb Boilerplate
A boilerplate for Node.js apps / GraphQL-API / Authentication from scratch - express, graphql - (graphql compose), mongodb (mongoose).
Stars: ✭ 288 (-1.71%)
Mutual labels:  api
Apilogger
Small laravel package for viewing api logs which can be used in debugging.
Stars: ✭ 285 (-2.73%)
Mutual labels:  api
Vulcain
Fast and idiomatic client-driven REST APIs.
Stars: ✭ 3,190 (+988.74%)
Mutual labels:  api
Weixin Spider
微信公众号爬虫,公众号历史文章,文章评论,文章阅读及在看数据,可视化web页面,可部署于Windows服务器。基于Python3之flask/mysql/redis/mitmproxy/pywin32等实现,高效微信爬虫,微信公众号爬虫,历史文章,文章评论,数据更新。
Stars: ✭ 287 (-2.05%)
Mutual labels:  api
Web Tooling Benchmark
JavaScript benchmark for common web developer workloads
Stars: ✭ 290 (-1.02%)
Mutual labels:  benchmark
Wildcard Api
Functions as API.
Stars: ✭ 286 (-2.39%)
Mutual labels:  api
Bench
A generic latency benchmarking library.
Stars: ✭ 286 (-2.39%)
Mutual labels:  benchmark
Mongorepository
Repository abstraction layer on top of Official MongoDB C# driver
Stars: ✭ 290 (-1.02%)
Mutual labels:  api
Covid Qa
API & Webapp to answer questions about COVID-19. Using NLP (Question Answering) and trusted data sources.
Stars: ✭ 283 (-3.41%)
Mutual labels:  api
Lanczosnetwork
Lanczos Network, Graph Neural Networks, Deep Graph Convolutional Networks, Deep Learning on Graph Structured Data, QM8 Quantum Chemistry Benchmark, ICLR 2019
Stars: ✭ 293 (+0%)
Mutual labels:  benchmark
Nodejs Restful Api
How to create a RESTful CRUD API using Nodejs?
Stars: ✭ 285 (-2.73%)
Mutual labels:  api
Node Zendesk
a zendesk API client library for use with node.js
Stars: ✭ 288 (-1.71%)
Mutual labels:  api
Pyaf
PyAF is an Open Source Python library for Automatic Time Series Forecasting built on top of popular pydata modules.
Stars: ✭ 289 (-1.37%)
Mutual labels:  benchmark
Graphql Apis
📜 A collective list of public GraphQL APIs
Stars: ✭ 3,525 (+1103.07%)
Mutual labels:  api
Nest Api
Unofficial Nest Learning Thermostat API
Stars: ✭ 293 (+0%)
Mutual labels:  api

api-benchmark

Greenkeeper badge

A node.js tool that measures and compares performances of single and multiple apis inspired by BenchmarkJs. Gitter

Why all of this? (blog post)

https://raw.github.com/matteofigus/api-benchmark-www/master/public/images/screen-shot.png

To see an example of a request/response look at this gist.

If you want to benchmark your api via grunt take a look at grunt-api-benchmark.

Requirements

Node version: min: 4, recommended: 8

Build status: Unix: Build Status | Windows: Build status

NPM

Installation

npm i api-benchmark

Usage

measure(service, routes, [options], callback)

Measures performances of a given api for multiple routes

var apiBenchmark = require('api-benchmark');

var service = {
  server1: 'http://myserver:myport/mypath/'
};

var routes = { route1: 'route1', route2: 'route2' };

apiBenchmark.measure(service, routes, function(err, results) {
  console.log(results);
  // displays some stats!
});

compare(services, routes, [options], callback)

Compares performances of a given list of api servers with the same routes. Useful in case of load balancers, globalised services, deployment of new versions.

var apiBenchmark = require('api-benchmark');

var services = {
  server1: 'http://myserver:myport/mypath/',
  server2: 'http://myserver2:myport2/mypath2/'
};

var routes = { route1: 'route1', route2: 'route2' };

apiBenchmark.compare(services, routes, function(err, results) {
  console.log(results);
  // displays some stats, including the winner!
});

All the Http verbs and headers are supported.

var apiBenchmark = require('api-benchmark');

var services = {
  server1: 'http://myserver:myport/mypath/',
  server2: 'http://myserver2:myport2/mypath2/'
};

var routes = {
  route1: {
    method: 'get',
    route: 'getRoute',
    headers: {
      Cookie: 'cookieName=value',
      Accept: 'application/json'
    }
  },
  route2: 'getRoute2',
  route3: {
    method: 'post',
    route: 'postRoute',
    data: {
      test: true,
      moreData: 'aString'
    }
  }
};

apiBenchmark.compare(services, routes, function(err, results) {
  console.log(results);
  // displays some stats, including the winner!
});

getHtml(results, callback)

Given a results object, gets the html report.

var apiBenchmark = require('api-benchmark');

var service = {
  server1: 'http://myserver:myport/mypath/'
};

var routes = { route1: 'route1', route2: 'route2' };

apiBenchmark.measure(service, routes, function(err, results) {
  apiBenchmark.getHtml(results, function(error, html) {
    console.log(html);
    // now save it yourself to a file and enjoy
  });
});

Route object

method

(String, default 'get'): Http verb.

route

(String): the route to benchmark

headers

(Object): the headers to send. In case of function (that has to return an object) it will be evaulated for each request.

data

(Object): the data sent with the request. In case of function (that has to return an object) it will be evaulated for each request.

query

(Object): the query sent with the request. In case of function (that has to return an object) it will be evaulated for each request.

expectedStatusCode

(Number, default null): if it is a number, generates an error when the status code of the response is different

maxMean

(Number, default null): if it is a number, generates an error when the mean value for a benchmark cycle is major than the expected value

maxSingleMean

(Number, default null): if it is a number, generates an error when the mean across all the concurrent requests value is major than the expected value

Options object

debug

(Boolean, default false): Displays some info on the console.

runMode

(String, default 'sequence'): Can be 'sequence' (each request is made after receiving the previous response) or 'parallel' (all requests are made in parallel).

maxConcurrentRequests

(Number, default 100): When in runMode='parallel' it is the maximum number of concurrent requests are made.

delay

(Number, default 0): When in runMode='sequence', it is the delay between test cycles (secs).

maxTime

(Number, default 10): The maximum time a benchmark is allowed to run before finishing (secs). Note: Cycle delays aren't counted toward the maximum time.

minSamples

(Number, default 20): The minimum sample size required to perform statistical analysis.

stopOnError

(Boolean, default true): Stops the benchmark as soon as it receives an error. When false, the benchmark goes on and the errors are collected inside the callback.

Tuning

You should tune your machine to remove any OS limits in terms of opening and quickly recycling sockets.

Linux and Mac OS X

sudo sysctl -w kern.maxfiles=25000
sudo sysctl -w kern.maxfilesperproc=24500
sudo sysctl -w kern.ipc.somaxconn=20000
ulimit -S -n 20000

Docker version

Containerized version of api-benchmark is available here: docker-api-benchmark

Contributing

This project is actively looking for contributors. If you wish to be involved, please open an issue and get in touch. Thanks!

For the latest updates and release information follow @matteofigus on twitter. Feel free to open new Issues in case of Bugs or Feature requests. Pull requests are welcome: first run all the tests locally doing npm test.

Tests

npm test

TODO

  • Command-line simple interface
  • Multi-thread requests
  • SOAP
  • Killer mode - ask for details

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].