HTTP/HTTPS load testing and benchmarking tool

Introduction

I wrote that code because: (the obvious reason::I love to write code in Go)

We are working so hard to optimize our servers - why shouldn't we do it for our clients testers?!

I noticed that the existing tools for benchmarking/load HTTP/HTTPS servers has some issues:

  • ab (ApacheBenchmark) - maximum concurrency is 20k (can be eliminate by opening multiple ab processes)
  • Siege are work in a model of native thread per request, meaning that you cannot simulated thousands/ten of thousands clients concurrently even if you tweak the RLIMIT of stack usage per native thread - still that kill the client machine and cause it to be very load and not an efficient client/s. What we really want is minimum resources usage and get the maximum throughput/load!

If you already familiar with the model of Go for high performance I/O with goroutines, we can achieve that mission easily.

The funny part - I did some benchmark to the client tester tool and not to the server:

##Siege vs GoBench:

###Siege:

$>siege -b -t10S -c500 http://localhost:80/

** SIEGE 2.70
** Preparing 500 concurrent users for battle.
The server is now under siege...
Lifting the server siege...      done.
Transactions:		       74247 hits
Availability:		      100.00 %
Elapsed time:		        9.62 secs
Data transferred:	       96.58 MB
Response time:		        0.06 secs
Transaction rate:	     7717.98 trans/sec
Throughput:		       10.04 MB/sec
Concurrency:		      490.19
Successful transactions:       74247
Failed transactions:	           0
Longest transaction:	        1.02
Shortest transaction:	        0.00

###GoBench:

$>gobench -k=true -u http://localhost:80 -c 500 -t 10
Dispatching 500 clients
Waiting for results...

Requests:                           343669 hits
Successful requests:                343669 hits
Network failed:                          0 hits
Bad requests failed (!2xx):              0 hits
Successfull requests rate:           34366 hits/sec
Read throughput:                  54700061 bytes/sec
Write throughput:                  4128684 bytes/sec
Test time:                              10 sec
  • requests hits and requests rate are 5X better on the same time (10 seconds) and the same number of clients (500)!
  • I tried the same with 2000 clients on Siege with proper system configuration, and Siege was crashed
  • I tried gobench with the maximum number of clients that we can use (65535 ports) - it's rocked!
  • Yet I didn't put the results of ab because I still need to investigate the results

Usage

  1. install Go env follow: https://golang.org/dl/

  2. download gobench

    GOPATH=/tmp/ go get github.com/valyala/fasthttp
    GOPATH=/tmp/ go get github.com/cmpxchg16/gobench
    
  3. run some http server on port 80

  4. run gobench for HTTP GET

    $>gobench -u http://localhost:80 -k=true -c 500 -t 10

  5. run gobench for HTTP POST

    $>gobench -u http://localhost:80 -k=true -c 500 -t 10 -d /tmp/post

Notes

  1. Because it's a test tool, in HTTPS the ceritificate verification is insecure
  2. use Go >= 1.5 (fasthttp require it)

Help

gobench --help

License

Licensed under the New BSD License.

Author

Uri Shamay ([email protected])

Owner
Uri Shamay
https://cmpxchg16.github.io
Uri Shamay
Comments
  • setting fasthttp MaxConnsPerHost to be equal to concurrency

    setting fasthttp MaxConnsPerHost to be equal to concurrency

    fasthttp has an internal default limit of 512 max connections per host. This causes network errors if you use a concurrency higher than 512. Made a change to set the fasthttp MaxConnsPerHost to be equal to the concurrency configured in the gobench execution.

    Before:

    $ gobench -c 750 -t 5 -u http://openresty/
    Dispatching 750 clients
    Waiting for results...
    Requests:                          4842824 hits
    Successful requests:                  5990 hits
    Network failed:                    4836833 hits
    Bad requests failed (!2xx):              0 hits
    Successful requests rate:             1198 hits/sec
    Read throughput:                   1435200 bytes/sec
    Write throughput:                   105332 bytes/sec
    Test time:                               5 sec
    

    After:

    $ ./gobench -c 750 -t 5 -u http://openresty/
    Dispatching 750 clients
    Waiting for results...
    Requests:                            52296 hits
    Successful requests:                 52296 hits
    Network failed:                          0 hits
    Bad requests failed (!2xx):              0 hits
    Successful requests rate:            10459 hits/sec
    Read throughput:                  11546956 bytes/sec
    Write throughput:                   859345 bytes/sec
    Test time:                               5 sec
    
  • How to hit a server on the internet like say http://google.com

    How to hit a server on the internet like say http://google.com

    I tried this gobench -u http://google.com/ -k=true -c 1 -r 1

    which results in

    Dispatching 1 clients
    Waiting for results...
    
    Requests:                                1 hits
    Successful requests:                     0 hits
    Network failed:                          0 hits
    Bad requests failed (!2xx):              1 hits
    Successful requests rate:                0 hits/sec
    Read throughput:                       552 bytes/sec
    Write throughput:                       82 bytes/sec
    Test time:                               1 sec
    

    Running gobench -u http://localhost:3000/ -k=true -c 1 -r 1 gives successful results as expected.

    Thanks in advance.

  • Display RPS/throughput as float64 instead of integer

    Display RPS/throughput as float64 instead of integer

    In high throughput low elapsed time situation, the request rate accuracy is very low.

    For example,

    $ ./gobench -c=1000 -r=10 -tc=10000 -tr=10000 -tw=10000 -u="<SAMPLE URL>"
    Dispatching 1000 clients
    Waiting for results...
    
    Requests:                            10000 hits
    Successful requests:                 10000 hits
    Network failed:                          0 hits
    Bad requests failed (!2xx):              0 hits
    Successfull requests rate:            5000 hits/sec
    Read throughput:                  24880000 bytes/sec
    Write throughput:                   720000 bytes/sec
    Test time:                               2 sec
    
    $ ./gobench -c=1000 -r=10 -tc=10000 -tr=10000 -tw=10000 -u="<SAMPLE URL>"
    Dispatching 1000 clients
    Waiting for results...
    
    Requests:                            10000 hits
    Successful requests:                 10000 hits
    Network failed:                          0 hits
    Bad requests failed (!2xx):              0 hits
    Successfull requests rate:            3333 hits/sec
    Read throughput:                  16586666 bytes/sec
    Write throughput:                   480000 bytes/sec
    Test time:                               3 sec
    

    This patch shows RPS/throughput as float instead of integer.

  • ulimit automatic assignment

    ulimit automatic assignment

    It would be convinient to have ulimit set automatically by GoBench, instead of me running ulimit -n 200000 each time I open a terminal for running GoBench.

  • Add more metrics to statistics summary

    Add more metrics to statistics summary

    The following metrics appearing in Siege summary are missing in GoBench summary when the test is done:

    • Concurrency
    • Throughput in MB/sec
    • Total bytes (they have a different name for that)
  • support for the url expression. And reduce the memory usage

    support for the url expression. And reduce the memory usage

    Three modifies:

    1. support for the url expression. so we can generate different url in a single url. It's useful when we want to test a web service with different arguments each times,such as login id
    2. statistic output changes a little
    3. use a more memory efficient way to recv the http body
  • GoBench stuck

    GoBench stuck

    ./gobench5 -c=25000 -d="postbig.txt" -k=true -r=1 -u="http://myurl" -tc=10000 -tw=10000 -tr=10000 -ta=300000

    postbig = ~0.5mb Running this is parallel from two computers, resulted in one client terminated after 226 seconds, while the other is stuck. There are ~25k connection on the server side.

  • Does not seem to work with IPv6

    Does not seem to work with IPv6

    test@debian:~$ curl -6 "http://[::1]/"
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
            width: 35em;
            margin: 0 auto;
            font-family: Tahoma, Verdana, Arial, sans-serif;
        }
    </style>
    </head>
    <body>
    <h1>Welcome to nginx!</h1>
    <p>If you see this page, the nginx web server is successfully installed and
    working. Further configuration is required.</p>
    
    <p>For online documentation and support please refer to
    <a href="http://nginx.org/">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="http://nginx.com/">nginx.com</a>.</p>
    
    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>
    
    test@debian:~$ ./gobench -t 5 -u "http://[::1]/"
    Dispatching 100 clients
    Waiting for results...
    
    Requests:                          1771986 hits
    Successful requests:                     0 hits
    Network failed:                    1771985 hits
    Bad requests failed (!2xx):              0 hits
    Successful requests rate:                0 hits/sec
    Read throughput:                         0 bytes/sec
    Write throughput:                        0 bytes/sec
    Test time:                               5 sec
    test@debian:~$ 
    
  • A rounding error

    A rounding error

    Hi. Sorry, I'm new to github, not sure if I did this by the book. I found a major rounding error in your calculations of requests/second, because you were dividing by the rounded number of seconds instead of the actual time passed. That would give you very incorrect results for short tests. I fixed it and I pushed it here:

    https://github.com/i-fail/gobench-windows

    I also needed a windows binary, which your repo didn't have, added that too.

    Thank you for this useful tool!

  • Post Json Request

    Post Json Request

    Hello,

    Please i have an application composed from two functions one is a get and the other one add function with post j son data , in this case how can i call this application using gobench.

    Thank you.

  • send interrupt signal to terminate the app is not available in windows

    send interrupt signal to terminate the app is not available in windows

    I just remove the dependency on: err := proc.Signal(os.Interrupt) which is not supported in windows. This should resolve issue: https://github.com/cmpxchg16/gobench/issues/19

Related tags
Replacement of ApacheBench(ab), support for transactional requests, support for command line and package references to HTTP stress testing tool.

stress stress is an HTTP stress testing tool. Through this tool, you can do a stress test on the HTTP service and get detailed test results. It is ins

Aug 23, 2022
An HTTP/HTTPS intercept proxy written in Go.
An HTTP/HTTPS intercept proxy written in Go.

Broxy Broxy is an open source intercept proxy written in Go. It makes use of goproxy as core proxy implementation and the interface is implemented wit

Nov 29, 2022
An HTTP performance testing tool written in GoLang

Gonce A HTTP API performance testing tool written in GoLang Description Installation Usage Description A performance testing tool written in GoLang. S

Jan 28, 2022
Go Supertest is minimalize HTTP Client Testing only for Gin Framework

Go Supertest is minimalize HTTP Client Testing only for Gin Framework, inspired by Supertest package library HTTP Client Testing for Express.js Framework.

May 22, 2022
Tiny-HTTPS protocol implementation (experiment purpose.)

thttps Basic TLS implementation in Go, written as a learning project. Most components are forked from Go version 1.7 tiny-HTTPS is not suitable for re

Mar 7, 2022
Custom domain args exposing https settings for c#

xyz Pulumi Component Provider (TypeScript) This repo is a boilerplate showing how to create a Pulumi component provider written in TypeScript. You can

Nov 30, 2021
Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http

fasthttp Fast HTTP implementation for Go. Currently fasthttp is successfully used by VertaMedia in a production serving up to 200K rps from more than

Jan 2, 2023
Speak HTTP like a local. (the simple, intuitive HTTP console, golang version)

http-gonsole This is the Go port of the http-console. Speak HTTP like a local Talking to an HTTP server with curl can be fun, but most of the time it'

Jul 14, 2021
Http client call for golang http api calls

httpclient-call-go This library is used to make http calls to different API services Install Package go get

Oct 7, 2022
fhttp is a fork of net/http that provides an array of features pertaining to the fingerprint of the golang http client.

fhttp The f stands for flex. fhttp is a fork of net/http that provides an array of features pertaining to the fingerprint of the golang http client. T

Jan 1, 2023
NATS HTTP Round Tripper - This is a Golang http.RoundTripper that uses NATS as a transport.

This is a Golang http.RoundTripper that uses NATS as a transport. Included is a http.RoundTripper for clients, a server that uses normal HTTP Handlers and any existing http handler mux and a Caddy Server transport.

Dec 6, 2022
Simple HTTP package that wraps net/http

Simple HTTP package that wraps net/http

Jan 17, 2022
Http-conection - A simple example of how to establish a HTTP connection using Golang

A simple example of how to establish a HTTP connection using Golang

Feb 1, 2022
A golang tool which makes http requests and prints the address of the request along with the MD5 hash of the response.

Golang Tool This repository is a golang tool which makes http requests to the external server and prints the address of the request along with the MD5

Oct 17, 2021
This is a simple single-host reverse proxy that intercept and save HTTP requests and responses
This is a simple single-host reverse proxy that intercept and save HTTP requests and responses

HTTP Telescope Debug HTTP requests using a reverse proxy. Description This is a simple single-host reverse proxy that intercept and save HTTP requests

Mar 20, 2022
Goget will send a http request, and show the request time, status, response, and save response to a file

Goget will send a http request, and show the request time, status, response, and save response to a file

Feb 9, 2022
Go (golang) http calls with retries and backoff

pester pester wraps Go's standard lib http client to provide several options to increase resiliency in your request. If you experience poor network co

Dec 28, 2022
Simple HTTP and REST client library for Go

Resty Simple HTTP and REST client library for Go (inspired by Ruby rest-client) Features section describes in detail about Resty capabilities Resty Co

Jan 1, 2023
A Go HTTP client library for creating and sending API requests
A Go HTTP client library for creating and sending API requests

Sling Sling is a Go HTTP client library for creating and sending API requests. Slings store HTTP Request properties to simplify sending requests and d

Jan 7, 2023