loadtest

package module
v0.0.0-...-6fb1997 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: MIT Imports: 14 Imported by: 0

README

Load Test Tool

This project provides a load testing tool for evaluating the performance of web services. It uses apib for generating load and is based off of Scott White's Load Testing article.

Features

  • Perform load tests with varying concurrency levels.
  • Predict optimal concurrency for a target latency.
  • Generate plots for latency and requests per second (RPS).

Requirements

  • Go 1.22 or later

Installation

  1. Clone the repository:

    git clone https://github.com/palmdalian/loadtest.git
    cd loadtest
    
  2. Build and push the Docker image:

    docker buildx create --use
    docker buildx build --progress=plain \
        --platform=linux/amd64,linux/arm64 \
        -f ./Dockerfile \
        -t $IMAGE \
        -o type=image,push=true .
    

Usage

  • It's best practice to run the loadtester from within your infrastructure. From within the docker image:

    loadtester -url <URL> -duration <DURATION> -target <TARGET_LATENCY> -concurrency <CONCURRENCY_LEVELS> [-check] [-plot]
    
    • -url: The URL to test (required).
    • -duration: Duration of each test in seconds (default: 10).
    • -target: Target latency (ms) for prediction (default: 100).
    • -concurrency: Comma-separated list of concurrency levels (default: "1,2,10,50,100,200").
    • -check: Re-run apib to check prediction (optional).
    • -plot: Generate plots (optional).
  • Example:

    loadtester -url http://example.com -duration 10 -target 100 -concurrency 1,2,10,50,100 -check -plot
    

Running locally

  1. Install apib

  2. Run the load test:

    go run cmd/main.go -url <URL> -duration <DURATION> -target <TARGET_LATENCY> -concurrency <CONCURRENCY_LEVELS> [-check] [-plot]
    
    • -url: The URL to test (required).
    • -duration: Duration of each test in seconds (default: 10).
    • -target: Target latency (ms) for prediction (default: 100).
    • -concurrency: Comma-separated list of concurrency levels (default: "1,2,10,50,100,200").
    • -check: Re-run apib to check prediction (optional).
    • -plot: Generate plots (optional).
  • Example:
    go run cmd/main.go -url http://example.com -duration 10 -target 100 -concurrency 1,2,10,50,100,200 -check -plot
    

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Contact

For any questions or feedback, please contact the project maintainer.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LatencyPercentile

type LatencyPercentile string
const (
	Latency50  LatencyPercentile = "50%"
	Latency90  LatencyPercentile = "90%"
	Latency98  LatencyPercentile = "98%"
	Latency99  LatencyPercentile = "99%"
	LatencyAvg LatencyPercentile = "avg"
)

type Runner

type Runner struct {
	URL               string
	Duration          int
	TargetLatency     int
	LatencyPercentile LatencyPercentile
	ConcurrencySteps  []int
	CheckPrediction   bool
	Plot              bool
}

func NewRunner

func NewRunner(url string, duration, targetLatency int, latencyPercentile LatencyPercentile, concurrency []int, checkPrediction, plot bool) *Runner

func (*Runner) Run

func (r *Runner) Run() (float64, error)

type TestResult

type TestResult struct {
	Name        string
	Throughput  float64
	AvgLatency  float64
	Threads     int
	Connections int
	Duration    float64
	Completed   int
	Successful  int
	Errors      int
	Sockets     int
	MinLatency  float64
	MaxLatency  float64
	Latency50   float64
	Latency90   float64
	Latency98   float64
	Latency99   float64
}

name,throughput,avg. latency,threads,connections,duration,completed,successful,errors,sockets,min. latency,max. latency,50%,90%,98%,99%

func (*TestResult) Latency

func (r *TestResult) Latency(percentile LatencyPercentile) float64

func (*TestResult) Print

func (r *TestResult) Print(latencyPercentile LatencyPercentile) string

func (*TestResult) String

func (r *TestResult) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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