Flexible HTTP command line stress tester for websites and web services

Overview

Pewpew Travis Go Report Card Coveralls branch GoDoc

Pewpew is a flexible command line HTTP stress tester. Unlike other stress testers, it can hit multiple targets with multiple configurations, simulating real world load and bypassing caches.

Disclaimer: Pewpew is designed as a tool to help those developing web services and websites. Please use responsibly.

Demo

Features

  • Multiple modes for measuring servers
  • Regular expression defined targets
  • Multiple simultaneous targets
  • No runtime dependencies, single binary file
  • Statistics on timing, data transferred, status codes, and more
  • Export raw data as TSV and/or JSON for analysis, graphs, etc.
  • HTTP2 support
  • IPV6 support
  • Tons of command line and/or config file options (arbitrary headers, cookies, User-Agent, timeouts, ignore SSL certs, HTTP authentication, Keep-Alive, DNS prefetch, and more)

Installing

Pre-compiled binaries for Windows, Mac, Linux, and BSD are available on Releases.

If you want to get the latest or build from source: install Go 1.11+ and either go get github.com/bengadbois/pewpew or git clone this repo.

Modes

Pewpew features two independent modes: stress and benchmark.

Stress mode (pewpew stress) sends requests as fast as the server can respond (limited by concurrency). This mode is usually best for answering questions such as "how fast can the server return 1000 requests?", "will the server ever OOM?", "can I get the server to 503?", and more related to overloading.

Benchmark mode (pewpew benchmark) sends requests at a fixed rate (requests per second). This mode is usually best for anwering questions such as "how much traffic can the server handle before latency surprasses 1 second?", "if traffic to the server is rate limited to 100 rps, will there by any 503s?", and other measurable controlled traffic tests.

Examples

pewpew stress -n 50 www.example.com

Make 50 requests to http://www.example.com

pewpew benchmark --rps 100 --duration 60 www.example.com

For 60 seconds, send 100 requests each second to www.example.com

pewpew stress -X POST --body '{"hello": "world"}' -n 100 -c 5 -t 2.5s -H "Accept-Encoding:gzip, Content-Type:application/json" https://www.example.com:443/path localhost 127.0.0.1/api

Make request to each of the three targets https://www.example.com:443/path, http://localhost, http://127.0.0.1/api

  • 100 requests total requests per target (300 total)
  • 5 concurrent requests per target (15 simultaneous)
  • POST with body {"hello": "world"}
  • Two headers: Accept-Encoding:gzip and Content-Type:application/json
  • Each request times out after 2.5 seconds

For the full list of command line options, run pewpew help or pewpew help stress

Using Regular Expression Targets

Pewpew supports using regular expressions (Perl syntax) to nondeterministically generate targets.

pewpew stress -r "localhost/pages/[0-9]{1,3}"

This example will generate target URLs such as:

http://localhost/pages/309
http://localhost/pages/390
http://localhost/pages/008
http://localhost/pages/8
http://localhost/pages/39
http://localhost/pages/104
http://localhost/pages/642
http://localhost/pages/479
http://localhost/pages/82
http://localhost/pages/3
pewpew stress -r "localhost/pages/[0-9]+\?cache=(true|false)(\&referrer=[0-9]{3})?"

This example will generate target URLs such as:

http://localhost/pages/278613?cache=false
http://localhost/pages/736?cache=false
http://localhost/pages/255?cache=false
http://localhost/pages/25042766?cache=false
http://localhost/pages/61?cache=true
http://localhost/pages/4561?cache=true&referrer=966
http://localhost/pages/7?cache=false&referrer=048
http://localhost/pages/01?cache=true
http://localhost/pages/767911706?cache=false&referrer=642
http://localhost/pages/68780?cache=true

Note: dots in IP addresses must be escaped, such as pewpew stress -r "http://127\.0\.0\.1:8080/api/user/[0-9]{1,3}"

Using Config Files

Pewpew supports complex configurations more easily managed with a config file. You can define one or more targets each with their own settings.

By default, Pewpew looks for a config file in the current directory and named pewpew.json or pewpew.toml. If found, Pewpew can be run like:

pewpew stress

There are examples config files in examples/.

Available global settings:

  • Count (default 10)
  • Concurrency (default 1)
  • NoHTTP2 (default false)
  • EnforceSSL (default false)
  • Quiet (default false)
  • Verbose (default false)
  • DNSPrefetch (default defer to Target)
  • Timeout (default defer to Target)
  • Method (default defer to Target)
  • Body (default defer to Target)
  • BodyFilename (default defer to Target)
  • Headers (default defer to Target)
  • Cookies (default defer to Target)
  • UserAgent (default defer to Target)
  • BasicAuth (default defer to Target)
  • Compress (default defer to Target)
  • KeepAlive (default defer to Target)
  • FollowRedirects (default defer to Target)

Available individual target settings:

  • URL (default "http://localhost")
  • RegexURL (default false)
  • DNSPrefetch (default false)
  • Timeout (default 10s)
  • Method (default GET)
  • Body (default empty)
  • RegexBody (default false)
  • BodyFilename (default none)
  • Headers (default none)
  • Cookies (default none)
  • UserAgent (default "pewpew")
  • BasicAuth (default none)
  • Compress (default false)
  • KeepAlive (default false)
  • FollowRedirects (default true)

Pewpew allows combining config file and command line settings, to maximize flexibility.

Individual target settings in the config file override any other setting, then command line flags (applied to all targets) override others, then global settings in the config file override the Pewpew's defaults.

If target URL(s) are specified on the command line, they override all targets in the config file.

Using as a Go library

package main

import (
    "fmt"
    "os"

    pewpew "github.com/bengadbois/pewpew/lib"
)

func main() {
    stressCfg := pewpew.StressConfig{
        //global settings
        Count:       1,
        Concurrency: 1,
        Verbose:     false,
        //setup one target
        Targets: []pewpew.Target{{
            URL:     "https://127.0.0.1:443/home",
            Timeout: "2s",
            Method:  "GET",
            Body:    `{"field": "data", "work": true}`,
        }},
    }

    //begin stress test
    output := os.Stdout //can be any io.Writer, such as a file
    stats, err := pewpew.RunStress(stressCfg, output)
    if err != nil {
        fmt.Printf("pewpew stress failed:  %s", err.Error())
    }

    //do whatever you want with the raw stats
    fmt.Printf("%+v", stats)
}

Full package documentation at godoc.org

Hints

If you receive a lot of "socket: too many open files" errors while running many concurrent requests, try increasing your ulimit.

Comments
  • Tomcat Vaadin Page loading times not accurate

    Tomcat Vaadin Page loading times not accurate

    I tested my Vaadin Page using your tool. I get an average response time of 50ms which can not be accurate since when opening the page with a browser I have about 2 seconds of waiting time, because vaadin uses ajax calls to generate site content it seems. Is there a way to configure a test so that it waits for the page to load completly?

    opened by faxe1008 3
  • fix misspelling of

    fix misspelling of "RSP" to be "RPS"

    A very basic little change: the acronym for "requests per second" (RPS) is misspelled as RSP in the console output here. This PR fixes it to be RPS as intended.

    That is all :-)

    opened by estraph 2
  • XML summary output

    XML summary output

    Before you submit a pull request, please make sure you have read and followed the contributing guidelines

    Description

    Please explain the changes you made here. Added possibility to output summary as xml file.

    Does this close any currently open issues?

    This doesn't close any issues.

    opened by ffest 2
  • The path of upload is wrong!Failed to make request: Post

    The path of upload is wrong!Failed to make request: Post "http://192.168.0.136:8199/admin/rank/SelectRankList": dial tcp 192.168.0.136:8199: connectex: Only one usage of each socket address (protocol/network address/port) is normally permitted.

    Failed to make request: Post "http://192.168.0.136:8199/admin/rank/SelectRankList": dial tcp 192.168.0.136:8199: connectex: Only one usage of each socket address (protocol/network address/port) is normally permitted.

    The path of upload is wrong!

    opened by 54huige 1
  • adding --body-regex option

    adding --body-regex option

    Before you submit a pull request, please make sure you have read and followed the contributing guidelines

    Description

    i added a new option --body-regex. this allows to generate different values (following the regex) at every request. my use-case where i needed that option, was when i wanted to make 10k user signup requests, where each request would have a unique username.

    pewpew stress -X POST --body-regex --body '{"username":"test_[a-z]{3,10}@(me|you)\.(org|net)","password":"secret123"}' -H "Content-Type:application/json" https://httpbin.org/post

    Does this close any currently open issues?

    No.

    opened by hzakher 1
  • Refactor and runtime memory optimization

    Refactor and runtime memory optimization

    Description

    Memory optimization via not pre-allocating every http request (see commit message for more)

    Does this close any currently open issues?

    Nope

    opened by bengadbois 1
  • Fix DNS prefetch parsing hostname from target URL

    Fix DNS prefetch parsing hostname from target URL

    Description

    Explicit port naming in the URL incorrectly caused a parsing error during DNS host lookup. This fixes it.

    Does this close any currently open issues?

    https://github.com/bengadbois/pewpew/issues/31

    opened by bengadbois 1
  • on the windows. run

    on the windows. run ".\pewpew.exe stress -X POST -n 50000 -c 1000 -t 3s -H "Accept-Encoding:gzip, Content-Type:application/json" http://192.168.0.136:9501"

    There are many wrong outputs!

    Failed to make request: Post "http://192.168.0.136:9501": dial tcp 192.168.0.136:9501: connectex: Only one usage of each socket address (protocol/network address/port) is normally permitted. Failed to make request: Post "http://192.168.0.136:9501": dial tcp 192.168.0.136:9501: connectex: Only one usage of each socket address (protocol/network address/port) is normally permitted. Failed to make request: Post "http://192.168.0.136:9501": dial tcp 192.168.0.136:9501: connectex: Only one usage of each socket address (protocol/network address/port) is normally permitted. Failed to make request: Post "http://192.168.0.136:9501": dial tcp 192.168.0.136:9501: connectex: Only one usage of each socket address (protocol/network address/port) is normally permitted. Failed to make request: Post "http://192.168.0.136:9501": dial tcp 192.168.0.136:9501: connectex: Only one usage of each socket address (protocol/network address/port) is normally permitted. HTTP/1.1 200 318 B 88 ms -> POST http://192.168.0.136:9501 HTTP/1.1 200 318 B 74 ms -> POST http://192.168.0.136:9501

    ----Summary----

    Timing Mean query speed: 139 ms Fastest query speed: 0 ms Slowest query speed: 2447 ms Mean RPS: 1277.07 req/sec Total time: 30097 ms

    Data Transferred Mean query: 318 B Largest query: 318 B Smallest query: 318 B Total: 12 MB

    Response Codes 200: 38437 responses (100.00%)

    opened by 54huige 2
Releases(v1.0.0)
Owner
Ben Gadbois
Ben Gadbois
Amazon Web Services (AWS) providerAmazon Web Services (AWS) provider

Amazon Web Services (AWS) provider The Amazon Web Services (AWS) resource provider for Pulumi lets you use AWS resources in your cloud programs. To us

William Garcia Jacobo 0 Nov 10, 2021
LinkPage is a FOSS self-hosted alternative to link listing websites such as LinkTree and Campsite.bio

LinkPage LinkPage is a FOSS self-hosted alternative to link listing websites such as LinkTree and Campsite.bio Features Self hostable and open source

Rohan Verma 50 Sep 20, 2022
Tigris is a modern, scalable backend for building real-time websites and apps.

Tigris Data Getting started These instructions will get you through setting up Tigris Data locally as Docker containers. Prerequisites Make sure that

Tigris Data Inc 383 Nov 21, 2022
Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.

HashiCorp 12.8k Nov 25, 2022
Kubei is a flexible Kubernetes runtime scanner, scanning images of worker and Kubernetes nodes providing accurate vulnerabilities assessment, for more information checkout:

Kubei is a vulnerabilities scanning and CIS Docker benchmark tool that allows users to get an accurate and immediate risk assessment of their kubernet

Portshift 806 Nov 24, 2022
A simple and flexible health check library for Go.

Health A simple and flexible health check library for Go. Documentation Β· Report Bug Β· Request Feature Table of Contents Getting started Synchronous v

Alexander Liesenfeld 627 Nov 9, 2022
This library provides a metrics package which can be used to instrument code, expose application metrics, and profile runtime performance in a flexible manner.

This library provides a metrics package which can be used to instrument code, expose application metrics, and profile runtime performance in a flexible manner.

null 0 Jan 18, 2022
Kubesecret is a command-line tool that prints secrets and configmaps data of a kubernetes cluster.

Kubesecret Kubesecret is a command-line tool that prints secrets and configmaps data of a kubernetes cluster. kubesecret -h for help pages. Install go

Charalampos Mitrodimas 18 May 3, 2022
Command kube-tmux prints Kubernetes context and namespace to tmux status line.

kube-tmux Command kube-tmux prints Kubernetes context and namespace to tmux status line.

null 7 Sep 10, 2021
This plugin helps you to use the AWS Command Line Interface (AWS CLI) to start and end sessions to your managed instances

Session Manager Plugin This plugin helps you to use the AWS Command Line Interface (AWS CLI) to start and end sessions to your managed instances. Sess

Amazon Web Services 175 Nov 15, 2022
A kafka command line browser

kcli Kcli is a kafka read only command line browser. Install Binaries are provided here (windows is not tested). If you have go (1.11 or greater) inst

Craig Swank 188 Nov 17, 2022
Command Line Interface for Scaleway

Scaleway CLI (v2) Scaleway CLI is a tool to help you pilot your Scaleway infrastructure directly from your terminal. Installation With a Package Manag

Scaleway 785 Nov 20, 2022
Command-line tool to remotely execute commands on Windows machines through WinRM

winrm-cli This is a Go command-line executable to execute remote commands on Windows machines through the use of WinRM/WinRS. Note: this tool doesn't

Brice Figureau 144 Oct 11, 2022
A command line tool for validating Kubernetes configs with rego

ccheck ccheck is a command line application for writing tests against configuration files and data using the rego query language. It's intended purpos

Brendan Ryan 63 Nov 16, 2022
🏯 Monitor your (gitlab/github) CI/CD pipelines via command line interface with fortress

__ _ / _| | | | |_ ___ _ __| |_ _ __ ___ ___ ___ | _/ _ \| '__| __| '__/ _ \/ __/ _

MrJosh 6 Mar 31, 2022
An unofficial command line utility for Futbin

futbin An unofficial command line utility for futbin. Also, it can be used as a library. Install Pre-compiled executables Get them here. Source You ne

Matheus Moraes 18 Nov 8, 2022
Igo Agent is the agent of Igo, a command-line tool, through which you can quickly start Igo

igo agent θ‹±ζ–‡ | δΈ­ζ–‡ Igo Agent is the agent of Igo, a command-line tool, through which you can quickly start Igo, and other capabilities may be added lat

null 1 Dec 22, 2021
The Coherence command line interface (CLI) is a lightweight tool, in the tradition of tools such as kubectl

Coherence Command Line Interface (CLI) Contents Overview Why use the Coherence C

Oracle 11 Oct 19, 2022
A command-line debugging tool to check the latency of SSL handshake

ssl-handshake A command-line tool for testing SSL handshake latency, written in

Puru 43 Nov 13, 2022