Giter Site home page Giter Site logo

thrash's Introduction

Thrash

Goals:

  • Mimic apache benchmark
  • Use yml to specify a list of URLs with a percentage for frequency
  • Measurements:
    • Min/Max/Avg/StdDev time per request
    • Requests/sec
    • endpoint distribution (for multiple endpoints)
Usage of ./thrash:
  -c int
    	The number of concurrent requests to execute. (default 1)
  -config string
    	File path to a configuration file (yml) (default "./config.yml")
  -n int
    	The total number of requests to make.

Example

Create a simple HTTP server for you to run some traffic to:

const http = require('http');

const hostname = '127.0.0.1';
const port = process.env.PORT || 3000;

const server = http.createServer((req, res) => {
  // console.log(`${req.method} ${req.url}`);
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.setHeader('Connection', 'close');
  res.end('Hello World\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

This server will respond to any path from the URL. The following config will cause thrash to generate requests for a few paths on the server:

root: "http://localhost:8000"
endpoints:
  - path: "/"
    freq: 30.0
  - path: "/foo"
    freq: -1.0
  - path: "/bar"
    freq: -1.0
  - path: "/qaz"
    freq: -1.0
  - path: "/qux"
    freq: -1.0
  - path: "/foobar"
    freq: -1.0

Note that the value of -1.0 signifies that thrash should evenly generate requests to those endpoints using the remaining percentage not specified by other endpoints.

Build thrash:

go build

Run thrash:

thrash -n 100000 -c 100

The default behavior is to read configuration from config.yml in the current directory, and you might get some output like this:

 ./thrash -n 100000 -c 100
Starting thrashing: 2019-01-30 22:11:33.049620102 -0500 EST m=+0.002806439
Completed requests: 10000	791.157283ms	Req/Sec: 12644.986
Completed requests: 20000	1.555646669s	Req/Sec: 13080.576
Completed requests: 30000	2.328958511s	Req/Sec: 12931.615
Completed requests: 40000	3.106834258s	Req/Sec: 12855.687
Completed requests: 50000	3.885333387s	Req/Sec: 12845.311
Completed requests: 60000	4.663884083s	Req/Sec: 12843.918
Completed requests: 70000	5.433084021s	Req/Sec: 13001.056
Completed requests: 80000	6.196982304s	Req/Sec: 13091.259
Completed requests: 90000	6.964151104s	Req/Sec: 13036.144
Completed requests: 100000	7.727599332s	Req/Sec: 13098.913

Request Summaries
=================================

http://localhost:8000/
  Count:   29752
  Success: 100 %
  Min:     0.9151600000000001 ms
  Max:     25.194368 ms
  Avg:     0s ms
  Freq:    29.999998 %

http://localhost:8000/foo
  Count:   14003
  Success: 100 %
  Min:     0.470042 ms
  Max:     27.246095 ms
  Avg:     0s ms
  Freq:    14.000002 %

http://localhost:8000/bar
  Count:   13988
  Success: 100 %
  Min:     0.62174 ms
  Max:     24.585356 ms
  Avg:     0s ms
  Freq:    14.000002 %

http://localhost:8000/qaz
  Count:   14070
  Success: 100 %
  Min:     0.236469 ms
  Max:     21.162565 ms
  Avg:     0s ms
  Freq:    14.000002 %

http://localhost:8000/qux
  Count:   13823
  Success: 100 %
  Min:     1.026119 ms
  Max:     25.167557 ms
  Avg:     0s ms
  Freq:    14.000002 %

http://localhost:8000/foobar
  Count:   14364
  Success: 100 %
  Min:     0.676328 ms
  Max:     23.483106 ms
  Avg:     0s ms
  Freq:    14.000002 %

Result Summary
=================================
  Req Count:   100000
  Concurrency: 100
  Duration:    7.727616414s
  Success:     100 %
  Req/Sec:     12940.600910111376

thrash's People

Contributors

johncoder avatar

Stargazers

Hugo avatar Greg Gamel avatar zach avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.