Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Load Tester

A high-performance API load testing tool built in Go, inspired by tools like JMeter and hey. Designed to generate concurrent HTTP traffic, measure latency, and produce actionable performance metrics.


✨ Features

  • Concurrent request execution using worker pools

  • Configurable total requests and concurrency

  • Measures:

    • Total requests
    • Success vs failure
    • Average latency
  • Graceful shutdown using context.Context

  • Modular, maintainable package structure

  • CLI-based usage


🧱 Project Structure

go-load-tester/
├── cmd/
│   └── loadtester/
│       └── main.go        # Application entry point
├── internal/
│   ├── config/            # Configuration management
│   ├── engine/            # Core load testing engine
│   │   ├── worker.go      # Worker pool logic
│   │   ├── dispatcher.go # Job dispatching
│   │   └── runner.go     # Test orchestration
│   ├── requester/         # HTTP request handling
│   ├── metrics/           # Thread-safe metrics collection
│   └── report/            # Summary report generation
├── go.mod
└── README.md

This structure follows Go best practices:

  • Clear separation of concerns
  • cmd/ for executable entry points
  • internal/ to prevent unwanted imports

⚙️ How It Works

  1. A dispatcher sends jobs into a channel

  2. Multiple workers (goroutines) consume jobs concurrently

  3. Each worker:

    • Sends an HTTP request
    • Measures response time
    • Records success or failure
  4. Metrics are aggregated safely using mutexes

  5. A summary report is generated at the end


🛠️ Installation

Make sure you have Go 1.21+ installed.

git clone https://github.com/JagTheFriend/Load-Testing-Tool.git
cd Load-Testing-Tool
go mod tidy

▶️ Usage

Run the load tester from the command line:

go run cmd/loadtester/main.go \
  -url https://example.com \
  -n 1000 \
  -c 50

CLI Flags

Flag Description
-url Target API endpoint (required)
-n Total number of requests
-c Number of concurrent workers

📊 Sample Output

====== Load Test Report ======
Total Requests: 1000
Successful:     987
Failed:         13
Average Latency:120ms
Test Duration:  3.4s

🧠 Key Technical Concepts Demonstrated

  • Goroutines & channels
  • Worker pool pattern
  • Thread-safe metrics aggregation
  • Context-based cancellation
  • Clean package design
  • CLI argument parsing

📈 Possible Enhancements

  • P95 / P99 latency calculations
  • Support for HTTP headers & request bodies
  • JSON / CSV report export
  • Rate limiting (RPS control)
  • Distributed load generation
  • Prometheus-compatible metrics output

About

A high-performance API load testing tool built in Go, inspired by tools like JMeter and hey. Designed to generate concurrent HTTP traffic, measure latency, and produce actionable performance metrics.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages