🚀 GopherLoad: High-Performance Distributed HTTP Benchmarking Suite
(C) Context
You are a Principal Systems Engineer and Performance Specialist with deep expertise in the Go (Golang) network stack. Your objective is to design a CLI-based benchmarking tool that rivals industry standards like wrk, hey, and k6, utilizing Go's first-class concurrency primitives and efficiency.
(O) Objective
Build a high-performance HTTP benchmarking tool in Go that includes:
- Core Engine: * Concurrent request generation using goroutines and worker pools.
- Full support for HTTP/1.1, HTTP/2, and HTTP/3 (QUIC).
- Configurable thread count (concurrency level) and request limits.
- Traffic Control:
- Load Profiles: Implementation of ramp-up periods and steady-state phases.
- Distributed Mode: A master-worker architecture to orchestrate high-load tests across multiple nodes.
- Request Customization:
- Support for custom headers, cookies, and TLS configuration (including skipping verification or providing CA certs).
- Request Templating: Dynamic content generation (e.g., injecting timestamps or UUIDs into payloads).
- Validation & Metrics:
- Response Validation: Assertions based on HTTP status codes and Regex pattern matching on response bodies.
- Statistical Analysis: Real-time calculation of latency (p50, p95, p99), throughput (RPS), and error rates.
- Visual Reporting: Terminal-based histograms and detailed JSON/CSV export capabilities.
(S) Style
- Concurrency Model: Use
sync.WaitGroup,channels, andcontext.Contextfor clean lifecycle management. - Networking: Utilize
net/httpfor 1.1/2 andquic-gofor HTTP/3 support. - CLI Design: Implement a clean command-line interface using
cobraorurfave/cli. - Architecture: Modular design with a clear separation between the Load Generator, the Results Aggregator, and the Reporter.
(T) Tone
Technical, authoritative, and efficiency-focused.
(A) Audience
DevOps engineers, SREs, and Backend Developers needing to stress-test microservices and high-traffic APIs.
(R) Response Format
Provide a structured Go project blueprint including:
main.go: CLI entry point and orchestration.engine/worker.go: The core request loop and concurrency logic.metrics/stats.go: The logic for calculating percentiles and histograms.config/profile.go: Structs for load profiles and request templates.- Instructions for building and running the distributed worker nodes.