8000 GitHub - linkxzhou/http_bench: golang HTTP stress testing tool, support single and distributed, http/1, http/2 and http/3.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

linkxzhou/http_bench

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

a HTTP(HTTP/1, HTTP/2, HTTP/3, Websocket, gRPC) stress testing tool, and support single and distributed.

build build build

http_bench is a tiny program that sends some load to a web application, support single and distributed mechine, http/1, http/2, http/3, websocket, grpc.

English Document
中文文档

  • HTTP/1 stress testing
  • HTTP/2 stress testing
  • HTTP/3 stress testing
  • Websocket stress testing
  • Distributed stress testing
  • Support functions
  • Support variable
  • Dashboard
  • TCP/UDP stress testing
  • Stepping stress testing
  • gRPC stress testing

avatar

Installation

NOTICE:go version >= 1.20

go get github.com/linkxzhou/http_bench

OR

git clone git@github.com:linkxzhou/http_bench.git
cd http_bench
go build .

Architecture

avatar

Example Usage

Single URL Testing

# Basic GET request with 1000 requests and 10 concurrent connections
./http_bench -n 1000 -c 10 -m GET -url "http://127.0.0.1/test1"
./http_bench -n 1000 -c 10 -m GET "http://127.0.0.1/test1"

Testing with URL List from File

# Random URL selection from a file with 1000 requests and 10 concurrent connections
./http_bench -n 1000 -c 10 -m GET "http://127.0.0.1/test1" -url-file urls.txt

# Duration-based test with POST requests and body payload
./http_bench -d 10s -c 10 -m POST -body "{}" -url-file urls.txt

HTTP/2 Testing

./http_bench -d 10s -c 10 -http http2 -m POST "http://127.0.0.1/test1" -body "{}"

HTTP/3 Testing

./http_bench -d 10s -c 10 -http http3 -m POST "http://127.0.0.1/test1" -body "{}"

WebSocket Testing

./http_bench -d 10s -c 10 -http ws "ws://127.0.0.1" -body "{}"

Distributed Stress Testing

# Step 1: Start worker instances on different machines
./http_bench -listen "127.0.0.1:12710" -verbose 1
./http_bench -listen "127.0.0.1:12711" -verbose 1

# Step 2: Run the controller to coordinate the test
./http_bench -c 1 -d 10s "http://127.0.0.1:18090/test1" -body "{}" -W "127.0.0.1:12710" -W "127.0.0.1:12711" -verbose 1

Web Dashboard

# Step 1: Start the dashboard server
./http_bench -dashboard "127.0.0.1:12345" -verbose 1

# Step 2: Open the dashboard URL in your browser
# http://127.0.0.1:12345

Template Functions and Variables

HTTP Bench supports dynamic request generation using template functions. These can be used in both URL parameters and request bodies.

1. Integer Sum

Calculates the sum of multiple integers.

# URL parameter
./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ intSum 1 2 3 4}}" -verbose 0

# Request body
./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ intSum 1 2 3 4 }}" -verbose 0

2. Random Integer

Generates a random integer between min and max values.

# URL parameter
./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ random 1 100000}}" -verbose 0

# Request body
./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ random 1 100000 }}" -verbose 0

3. Random Date

Generates a random date string in the specified format.

# URL parameter
./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ randomDate 'YMD' }}" -verbose 0

# Request body
./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ randomDate 'YMD' }}" -verbose 0

4. Random String

Generates a random alphanumeric string of specified length.

# URL parameter
./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ randomString 10}}" -verbose 0

# Request body
./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ randomString 10 }}" -verbose 0

5. Random Number String

Generates a random numeric string of specified length.

# URL parameter
./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ randomNum 10}}" -verbose 0

# Request body
./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ randomNum 10 }}" -verbose 0

6. Current Date

Outputs the current date in the specified format.

# URL parameter
./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ date 'YMD' }}" -verbose 0

# Request body
./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ date 'YMD' }}" -verbose 0

7. UUID

Generates a UUID.

# URL parameter
./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ UUID | escape }}" -verbose 0

# Request body
./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ UUID }}" -verbose 0

8. String Escape

Escapes special characters in a string.

# URL parameter
./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ UUID | escape }}" -verbose 0

# Request body
./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ UUID | escape }}" -verbose 0

9. Hex to String

Converts a hexadecimal string to a regular string.

# URL parameter
./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ hexToString '68656c6c6f20776f726c64' }}" -verbose 0

# Request body
./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ hexToString '68656c6c6f20776f726c64' }}" -verbose 0

10. String to Hex

Converts a string to its hexadecimal representation.

# URL parameter
./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ stringToHex 'hello world' }}" -verbose 0

# Request body
./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ stringToHex 'hello world' }}" -verbose 0

11. To String

Converts a value to a quoted string.

# URL parameter
./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ randomNum 10 | toString }}" -verbose 0

# Request body
./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ randomNum 10 | toString }}" -verbose 0

Troubleshooting

macOS Catalina Build Error

If you encounter the error pointer is missing a nullability type specifier when building on catalina, use the following workaround:

export CGO_CPPFLAGS="-Wno-error -Wno-nullability-completeness -Wno-expansion-to-defined"

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

golang HTTP stress testing tool, support single and distributed, http/1, http/2 and http/3.

Topics

golang benchmark stress websocket http2 < 59AC a href="/topics/distributed" title="Topic: distributed" data-view-component="true" class="topic-tag topic-tag-link"> distributed httpclient stress-testing tiny-tools http3 http1 httpbench

Resources

Stars

Watchers

Forks

Packages

No packages published
0