go-wrk - a HTTP benchmarking tool based in spirit on the excellent wrk tool (https://github.com/wg/wrk)

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 get github.com/tsliwowicz/go-wrk  

This will download and compile go-wrk. The binary will be placed under your $GOPATH/bin directory

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

   Usage: go-wrk <options> <url>
   Options:
    -H 	 header line, joined with ';' (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)
    -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.

Comments
  • Allow -body to be a folder of .json files

    Allow -body to be a folder of .json files

    • Use case:
    1. Randomize the payload when firing off requests
    • Proposal:
    1. Pass in folder name by denoting a # at the beginning of the body
    2. .json files in the folder will be added to a file array
    3. When making the requests, go-wrk will randomly choose one of the .json files
  • -f option

    -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/

  • Add header line support

    Add header line support

    Add header line support in request for setting things like Content-Type, Content-Language, etc. Multiple headers are joined with semicolon.

    Change the original -H flag to -host, and use the -H as header flag

    Update the READEME.md about the changed flag

  • How to send post data value in go-wrk command?

    How to send post data value in go-wrk command?

    curl -X POST -d'{"accountID":"1"}' localhost:1234/getInfo How am I supposed to send accountID value in go-wrk command for a post request

  • go.mod contains replace directives

    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.

  • ability to pass mulitple -H options for headers

    ability to pass mulitple -H options for headers

    This way we can pass cookie headers where ; is contained in header value, as we are no longer splitting on any special character.

    fixes issue https://github.com/tsliwowicz/go-wrk/issues/14

  • Skip verifying server certificate option

    Skip verifying server certificate option

    For testing locally it's convenient to disable SSL certificates validation. To avoid errors:

    An error occured doing request Post "https://127.0.0.3/f": x509: cannot validate certificate for 127.0.0.3 because it doesn't contain any IP SANs

    so I added an option -no-vr to disable sertificate validation. By default it's enabled

  • Doesn't support post data?

    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?

  • bug in header when passing value key1: key2

    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 ....

  • ";" 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 `

  • Add header line support

    Add header line support

    Add header line support in request for setting things like Content-Type, Content-Language, etc. Multiple headers are joined with semicolon.

    Change the original -H flag to -host, and use the -H as header flag.

  • Parsing Error for Playback File

    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
    
  • Treat all 2XX as successful

    Treat all 2XX as successful

    @tsliwowicz Great tool! I'm using this to load test an endpoint that returns 202 on success, and currently go-wrk is treating this as a failure.

    Would you be open to merging this? Also, I have an automatic formatter, but happy to undo those formatting changes if you'd prefer.

    Thank you!

a benchmarking&stressing tool that can send raw HTTP requests

reqstress reqstress is a benchmarking&stressing tool that can send raw HTTP requests. It's written in Go and uses fasthttp library instead of Go's def

Dec 18, 2022
Plow is a high-performance HTTP benchmarking tool with real-time web UI and terminal displaying
Plow is a high-performance HTTP benchmarking tool with real-time web UI and terminal displaying

Plow is a HTTP(S) benchmarking tool, written in Golang. It uses excellent fasthttp instead of Go's default net/http due to its lightning fast performance.

Jan 9, 2023
HTTP mock for Golang: record and replay HTTP/HTTPS interactions for offline testing

govcr A Word Of Warning I'm in the process of partly rewriting govcr to offer better support for cassette mutations. This is necessary because when I

Dec 28, 2022
Stress testing and benchmarking tool for the NEAR EVM

evm-bully --- stress testing and benchmarking tool for the NEAR EVM

May 30, 2022
Benchmarking hash functions in Go

Experiment: Benchmarks of Hash Functions in Go This repository contains a small experiment of mine, trying out different hash functions and comparing

Jun 22, 2022
Benchmarking deferent Fibonacci functions and algorithms with running unit test

GoFibonacciBench Benchmarking deferent Fibonacci functions and algorithms with running unit test ... Introduction: Fibonacci numbers are special kinds

Feb 27, 2022
Aquatone is a tool for visual inspection of websites across a large amount of hosts and is convenient for quickly gaining an overview of HTTP-based attack surface.

Aquatone is a tool for visual inspection of websites across a large amount of hosts and is convenient for quickly gaining an overview of HTTP-based attack surface.

Jan 6, 2023
📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs.
 📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs.

mock ?? mock is a simple, cross-platform, cli app to simulate HTTP-based APIs. About mock Mock allows you to spin up a local http server based of a .m

May 6, 2022
:octocat: ghdag is a tiny workflow engine for GitHub issue and pull request.

ghdag ghdag is a tiny workflow engine for GitHub issue and pull request. Key features of ghdag are: Simple definition of workflows to improve the life

Nov 5, 2022
A library to aid unittesting code that uses Golang's Github SDK

go-github-mock A library to aid unittesting code that uses Golang's Github SDK Installation go get github.com/migueleliasweb/go-github-mock Features C

Dec 30, 2022
Example usage of github.com/go-webauthn/webauthn

Example This is an example go + React application which shows off the functionality of the github.com/go-webauthn/webauthn library. Features This proj

Sep 26, 2022
HTTP load testing tool and library. It's over 9000!
HTTP load testing tool and library. It's over 9000!

Vegeta Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a

Jan 7, 2023
Ditto is a CLI testing tool that helps you verify if multiple HTTP endpoints have the same outputs.

Ditto is a CLI testing tool that helps you verify if multiple HTTP endpoints have the same outputs.

Nov 24, 2021
A tool that integrates SQL, HTTP,interface,Redis mock

Mockit 目标:将mock变得简单,让代码维护变得容易 分支介绍 main 主分支,覆盖了单元测试 light 轻分支,去除了单元测试,简化了依赖项,方便其他团队使用 常见Mock难点 不同中间件,mock库设计模式不一致,学习代价高,差异化明显 mock方案强依赖服务端,无法灵活解耦 单元测试

Sep 22, 2022
Client tool for testing HTTP server timeouts

HTTP timeout test client While testing Go HTTP server timeouts I wrote this little tool to help me test. It allows for slowing down header write and b

Sep 21, 2022
Package has tool to generate workload for vegeta based kube-api stress tests.

Package has tool to generate workload for vegeta based kube-api stress tests.

Nov 22, 2021
Expressive end-to-end HTTP API testing made easy in Go

baloo Expressive and versatile end-to-end HTTP API testing made easy in Go (golang), built on top of gentleman HTTP client toolkit. Take a look to the

Dec 13, 2022
Golang HTTP client testing framework

flute Golang HTTP client testing framework Presentation https://speakerdeck.com/szksh/flute-golang-http-client-testing-framework Overview flute is the

Sep 27, 2022
http integration test framework

go-hit hit is an http integration test framework written in golang. It is designed to be flexible as possible, but to keep a simple to use interface f

Dec 29, 2022