Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
api-benchmark
Advanced tools
Readme
A node.js tool that measures and compares performances of single and multiple apis inspired by BenchmarkJs.
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.
Route
objectOptions
objectNode version: min: 4, recommended: 8
Build status: Unix: | Windows:
npm i api-benchmark
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!
});
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!
});
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
});
});
(String, default 'get'): Http verb.
(String): the route to benchmark
(Object): the headers to send. In case of function (that has to return an object) it will be evaulated for each request.
(Object): the data sent with the request. In case of function (that has to return an object) it will be evaulated for each request.
(Object): the query sent with the request. In case of function (that has to return an object) it will be evaulated for each request.
(Number, default null): if it is a number, generates an error when the status code of the response is different
(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
(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
(Boolean, default false): Displays some info on the console.
(String, default 'sequence'): Can be 'sequence' (each request is made after receiving the previous response) or 'parallel' (all requests are made in parallel).
(Number, default 100): When in runMode='parallel' it is the maximum number of concurrent requests are made.
(Number, default 0): When in runMode='sequence', it is the delay between test cycles (secs).
(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.
(Number, default 20): The minimum sample size required to perform statistical analysis.
(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.
You should tune your machine to remove any OS limits in terms of opening and quickly recycling sockets.
sudo sysctl -w kern.maxfiles=25000
sudo sysctl -w kern.maxfilesperproc=24500
sudo sysctl -w kern.ipc.somaxconn=20000
ulimit -S -n 20000
Containerized version of api-benchmark is available here: docker-api-benchmark
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
.
npm test
MIT
FAQs
A simple nodejs tool to measure and compare performances of api services
The npm package api-benchmark receives a total of 467 weekly downloads. As such, api-benchmark popularity was classified as not popular.
We found that api-benchmark demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.