package httpbench
import "gvisor.dev/gvisor/test/kubernetes/benchmarks/httpbench"
Package httpbench provides a library for benchmarking an HTTP server.
Index ¶
Constants ¶
const InfiniteQPS = 1 << 16
InfiniteQPS is a stand-in value for "a lot of QPS". Running a benchmark round at this load level amounts to saturating the HTTP server with load on a single connection.
Types ¶
type HTTPBenchmark ¶
type HTTPBenchmark struct { // Name is the name of the benchmark. It is used as a prefix for all // benchstat output metrics. Name string // Cluster is the test cluster. Cluster *testcluster.TestCluster // Namespace is the benchmark namespace where pods are created. Namespace *testcluster.Namespace // Service is a Kubernetes service pointing to the HTTP server. Service *v13.Service // Port is the port that the HTTP server is bound to. Port int // Path is the HTTP path that the benchmark should use in its requests. // It should start by "/", e.g. "/index.html". Path string // Timeout is the maximum allowable duration of requests for Path. Timeout time.Duration // Rounds is the set of rounds to run the benchmark for. Must be non-empty. Rounds []Round // WantPercentiles is the list of percentiles to report. WantPercentiles []int }
HTTPBenchmark helps manage an HTTP-based benchmark. A benchmark that wishes to run an HTTP-based benchmark should set up the HTTP server pod and a Kubernetes Service pointing at it, and this library takes care of the rest.
func (*HTTPBenchmark) Run ¶
func (h *HTTPBenchmark) Run(ctx context.Context, t *testing.T)
Run runs the HTTP-based benchmark.
type MetricType ¶
type MetricType int
MetricType is a type of metric to report.
const ( Latency MetricType = iota RequestsPerSecond BytesPerSecond )
List of metric types.
type Round ¶
type Round struct { // NumThreads is the number of concurrent threads and connections to make. NumThreads int // TargetQPS is the aggregate load on the server that will be spread across // the `NumThreads` threads. TargetQPS int // Duration is the total duration of the round. It should be longer than 10s // as wrk2 uses the first 10 seconds as calibration period. Duration time.Duration // If set, only report the metric types listed here. OnlyReport []MetricType }
Round is a single round of benchmarking.
Source Files ¶
httpbench.go
- Version
- v0.0.0-20250605235530-a6711d1e1dc6 (latest)
- Published
- Jun 5, 2025
- Platform
- linux/amd64
- Imports
- 14 packages
- Last checked
- 4 hours ago –
Tools for package owners.