Git Product home page Git Product logo

go-wrk's Introduction

go-wrk - an HTTP benchmarking tool

go-wrk is a modern HTTP benchmarking tool capable of generating significant load when run on a single multi-core CPU. It builds on go language go routines and scheduler for behind the scenes async IO and concurrency.

It was created mostly to examine go language (http://golang.org) performance and verbosity compared to C (the language wrk was written in. See - https://github.com/wg/wrk).
It turns out that it is just as good in terms of throughput! And with a lot less code.

The majority of go-wrk is the product of one afternoon, and its quality is comparable to wrk.

Building

go install github.com/tsliwowicz/go-wrk@latest

This will download and compile go-wrk.

Command line parameters (./go-wrk -help)

   Usage: go-wrk <options> <url>
   Options:
    -H       Header to add to each request (you can define multiple -H flags) (Default )
    -M       HTTP method (Default GET)
    -T       Socket/request timeout in ms (Default 1000)
    -body    request body string or @filename (Default )
    -c       Number of goroutines to use (concurrent connections) (Default 10)
    -ca      CA file to verify peer against (SSL/TLS) (Default )
    -cert    CA certificate file to verify peer against (SSL/TLS) (Default )
    -d       Duration of test in seconds (Default 10)
    -f       Playback file name (Default <empty>)
    -help    Print help (Default false)
    -host    Host Header (Default )
    -http    Use HTTP/2 (Default true)
    -key     Private key file name (SSL/TLS (Default )
    -no-c    Disable Compression - Prevents sending the "Accept-Encoding: gzip" header (Default false)
    -no-ka   Disable KeepAlive - prevents re-use of TCP connections between different HTTP requests (Default false)
    -no-vr   Skip verifying SSL certificate of the server (Default false)
    -redir   Allow Redirects (Default false)
    -v       Print version details (Default false)

Basic Usage

./go-wrk -c 80 -d 5  http://192.168.1.118:8080/json

This runs a benchmark for 5 seconds, using 80 go routines (connections)

Output:

Running 10s test @ http://192.168.1.118:8080/json
  80 goroutine(s) running concurrently
   142470 requests in 4.949028953s, 19.57MB read
     Requests/sec:		28787.47
     Transfer/sec:		3.95MB
     Avg Req Time:		0.0347ms
     Fastest Request:	0.0340ms
     Slowest Request:	0.0421ms
     Number of Errors:	0

Benchmarking Tips

The machine running go-wrk must have a sufficient number of ephemeral ports available and closed sockets should be recycled quickly. To handle the initial connection burst the server's listen(2) backlog should be greater than the number of concurrent connections being tested.

Acknowledgements

golang is awesome. I did not need anything but this to create go-wrk.
I fully credit the wrk project (https://github.com/wg/wrk) for the inspiration and even parts of this text.
I also used similar command line arguments format and output format.

go-wrk's People

Contributors

advincze avatar dependabot[bot] avatar dtuck9 avatar elodani avatar iketheadore avatar pin2t avatar trayo avatar tsliwowicz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-wrk's Issues

";" in header value

If there are two or more cookie value in "Cookie", their delimiter is ";".
"Accept-Language", "User-Agent" might contains ";" too.
So, when there are multiple headers in -H, these headers raise a panic error.
Example headers are:
`
Cookie: _ga=GA1.1.1691826; io=wSaVgyAsiDtAAAd; sbs=kQzmcq4t;

Accept-Language: zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-CN;q=0.6,fr;q=0.5,ja;q=0.4

User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) Safari/537.36
`

-f option

Does the -f option call a file with a list of URLs ?
If so, can you provide an brief description on how to
use the file. As well as an example showing the format of the file ?

I tried using a conventional URL, and go-wrk complained.

http://www.abc.com/

Parsing Error for Playback File

The playback file option produces parsing error An error occured doing request parse "http://www.google.com/\n": net/url: invalid control character in URL.

Issue observed on OSX v12.5.1 and on golang:alpine docker image.

Replication Steps:
go install github.com/tsliwowicz/go-wrk@latest
echo http://www.google.com > /tmp/playbackfile.txt
./go-wrk -c 1 -d 1 -f /tmp/playbackfile.txt

Observe the following output:

Running 1s test @ http://www.google.com

  1 goroutine(s) running concurrently
An error occured doing request parse "http://www.google.com\n": net/url: invalid control character in URL

bug in header when passing value key1: key2

go-wrk -H "Authorization: Basic key1:key2"

this will bugar because it is doing split with ":" if the header has another ":" error will occur.
this will bugar because it is doing split with ":" if the header has another ":" error will occur.
Picking up only Key1

received status code 401 from map[Date:[Fr ....

go.mod contains replace directives

go.mod with replace directives give this warning:

$ go install github.com/tsliwowicz/go-wrk@latest
go: downloading github.com/tsliwowicz/go-wrk v0.0.0-20210628064207-cc6865c14ec7
go: github.com/tsliwowicz/go-wrk@latest (in github.com/tsliwowicz/[email protected]):
	The go.mod file for the module providing named packages contains one or
	more replace directives. It must not contain directives that would cause
	it to be interpreted differently than if it were the main module.
$

I removed the replace directives and it did work nicely.

Doesn't support post data?

The command line has a "-body" parameter, yet the code seems doesn't attach the data to the HTTP request:
image

req only attaches some header lines before got sent. So is this sth that haven't implemented?

HTTPS support

It would be nice if go-wrk would have support for doing https requests.

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.