httpbench

package
v0.0.0-...-b4fcc37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package httpbench provides a library for benchmarking an HTTP server.

Index

Constants

View Source
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.

Variables

This section is empty.

Functions

This section is empty.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL