Skip to content

memran/go-loadtest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

HTTP Load Testing Tool

Build Status Latest Release Go Version License Downloads

A simple and powerful HTTP load testing tool written in Go. Perform concurrent HTTP load tests against any web endpoint with configurable parameters.

Features

  • ⚑ High Performance: Concurrent request handling with connection pooling
  • 🎯 Configurable: Adjustable request count, concurrency levels, timeouts, and overall test timeout
  • πŸ“Š Real-time Metrics: Live progress tracking and detailed results
  • πŸ”’ Secure: Optional TLS verification with clear warnings for insecure mode
  • πŸš€ Fast: Single binary with no external dependencies
  • πŸ’» Cross-platform: Works on Windows, macOS, and Linux
  • πŸ“¦ Request Body Support: Test POST/PUT/PATCH requests with custom JSON bodies
  • πŸ” Authentication: Basic Auth and Bearer token support
  • βœ… Input Validation: Validates URLs, HTTP methods, and parameters
  • πŸ“ Smart Logging: Throttled logging to avoid output spam

Quick Start

# Clone the repository
git clone https://github.com/memran/go-loadtest.git
cd go-loadtest

# Run a basic load test
go run main.go -url https://httpbin.org/get -requests 1000 -concurrency 50

# View all options
go run main.go --help

Usage Examples

Basic GET Request Test

go run main.go -url https://httpbin.org/get -requests 100 -concurrency 10

High Concurrency Test

go run main.go -url https://api.example.com -requests 10000 -concurrency 100 -timeout 60

POST Request with JSON Body

go run main.go -url https://httpbin.org/post -method POST \
  -body '{"name":"test","value":123}' -requests 100 -concurrency 10

Test with Basic Authentication

go run main.go -url https://httpbin.org/basic-auth/user/pass \
  -auth-user user -auth-pass pass -requests 50 -concurrency 5

Test with Bearer Token

go run main.go -url https://httpbin.org/bearer \
  -bearer-token "your-token-here" -requests 100 -concurrency 10

Test with Overall Timeout

# Stop the entire test after 30 seconds, regardless of pending requests
go run main.go -url https://api.example.com -requests 10000 \
  -concurrency 100 -total-timeout 30

Test with Insecure SSL (Development Only)

go run main.go -url https://self-signed.example.com -insecure \
  -requests 100 -concurrency 10

Disable HTTP Keep-Alive

go run main.go -url https://example.com -keepalive=false -requests 100 -concurrency 10

Command Line Options

Option Description Default
-url URL to test https://httpbin.org/get
-requests Number of requests 100
-concurrency Number of concurrent requests 10
-timeout Request timeout in seconds 30
-total-timeout Total test timeout in seconds (0 for no timeout) 0
-method HTTP method (GET, POST, PUT, DELETE, PATCH, HEAD) GET
-body Request body (for POST/PUT/PATCH) ``
-auth-user Username for basic authentication ``
-auth-pass Password for basic authentication ``
-bearer-token Bearer token for authentication ``
-keepalive Use HTTP keep-alive true
-insecure Skip TLS verification false

Building from Source

# Clone the repository
git clone https://github.com/memran/go-loadtest.git
cd go-loadtest

# Build the binary
go build -o loadtest main.go

# Run the built binary
./loadtest -url https://api.example.com -requests 1000

Requirements

  • Go 1.19 or higher

Output Example

πŸš€ Starting HTTP Load Test
πŸ“ URL: https://api.example.com
πŸ”’ Requests: 1000, Concurrency: 50
⏱️  Timeout: 30s, Method: GET
⏱️  Total Test Timeout: 300s

πŸ“Š Progress: 200/1000 (20.0%) - Rate: 100.5 req/sec
πŸ“Š Progress: 400/1000 (40.0%) - Rate: 102.3 req/sec
πŸ“Š Progress: 600/1000 (60.0%) - Rate: 98.7 req/sec
πŸ“Š Progress: 800/1000 (80.0%) - Rate: 101.2 req/sec
πŸ“Š Progress: 1000/1000 (100.0%) - Rate: 99.8 req/sec

============================================================
πŸŽ‰ LOAD TEST COMPLETED!
============================================================
πŸ“ URL: https://api.example.com
⏱️  Total Time: 10.02 seconds
πŸ“Š Total Requests: 1000
βœ… Successful: 980
❌ Failed: 20
πŸ“ˆ Success Rate: 98.00%
πŸš€ Requests/Second: 99.80
πŸ”€ Concurrency: 50
⚑ Method: GET
πŸ”’ Keep-Alive: true
⏱️  Total Timeout: 300s
πŸ”“ Insecure: false
============================================================

Example with Authentication and Body

πŸš€ Starting HTTP Load Test
πŸ“ URL: https://httpbin.org/post
πŸ”’ Requests: 100, Concurrency: 10
⏱️  Timeout: 30s, Method: POST
πŸ“¦ Body: {"test":"data"}
πŸ” Auth: Basic (user)

βœ… Request 0: Status 200 (1191.80ms)
βœ… Request 1: Status 200 (793.49ms)
πŸ“Š Progress: 30/100 (30.0%) - Rate: 15.0 req/sec
...

============================================================
πŸŽ‰ LOAD TEST COMPLETED!
============================================================
πŸ“ URL: https://httpbin.org/post
⏱️  Total Time: 6.52 seconds
πŸ“Š Total Requests: 100
βœ… Successful: 100
❌ Failed: 0
πŸ“ˆ Success Rate: 100.00%
πŸš€ Requests/Second: 15.34
πŸ”€ Concurrency: 10
⚑ Method: POST
πŸ”’ Keep-Alive: true
πŸ”“ Insecure: false
============================================================

Input Validation

The tool validates all inputs before starting the test:

  • URL: Must start with http:// or https://
  • HTTP Method: Only allows GET, POST, PUT, DELETE, PATCH, HEAD
  • Requests/Concurrency/Timeout: Must be positive integers
  • Total Timeout: Must be non-negative
  • Body: Cannot be used with GET, HEAD, or DELETE methods
  • Authentication: Cannot use both Basic Auth and Bearer Token simultaneously

Security ⚠️

Important: When using the -insecure flag, be aware that you're bypassing TLS certificate validation. Only use this option in trusted development environments. Never use it for production traffic or with sensitive data.

Logging Strategy

The tool uses smart logging to avoid output spam:

  • First 10 requests (success or failure) are always logged
  • Successful requests: logged every 100th request after the first 10
  • Failed requests (non-2xx): logged every 50th request
  • Network errors: logged every 100th error

License

This project is licensed under the MIT License.

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Releases

Automated Releases (Recommended)

This project uses GitHub Actions for automated cross-platform releases.

To create a release:

  1. Tag your commit with a version number:

    git tag v1.0.0
  2. Push the tag to GitHub:

    git push origin v1.0.0
  3. GitHub Actions will automatically:

    • Build binaries for Linux (amd64, arm64), macOS (Intel, Apple Silicon), and Windows (amd64, 386)
    • Create a GitHub Release
    • Attach all binaries to the release

Manual Builds

Linux/macOS:

chmod +x build.sh
./build.sh v1.0.0

Windows (PowerShell):

.\build.ps1 -Version "v1.0.0"

Binaries will be created in the build/ directory.

Version Information

Check the version of a built binary:

./go-loadtest --version
# Output: go-loadtest version v1.0.0

Roadmap

  • Request body support
  • Authentication (Basic Auth, Bearer tokens)
  • Custom headers
  • JSON/CSV output formats
  • HTML report generation
  • Rate limiting
  • More detailed metrics (latency percentiles, throughput graphs)
  • Proxy support
  • Cookie/session support

About

A simple and powerful HTTP load testing tool written in Go

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors