Giter Club home page Giter Club logo

pewpew's Introduction

Pewpew Workflow 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/.

Pewpew allows combining config file and command line settings, to maximize flexibility. Pewpew uses https://github.com/spf13/viper and follows its rules of config precedence.

Other Options

The full list of options for each command can be viewed by running Pewpew with the --help flag.

Using as a Go library

package main

import (
    "fmt"
    "os"

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

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

    output := os.Stdout
    stats, err := pewpew.RunStress(stressCfg, output)
    if err != nil {
        fmt.Printf("pewpew stress failed:  %s", err.Error())
    }

    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.

pewpew's People

Contributors

bengadbois avatar ffest avatar hzakher avatar thomwiggers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pewpew's Issues

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%)

Make pewpew available as a package in package managers such as brew, apt

I'm not sure if it fits under guidelines, since it's not directly related to tool itself, but I've felt that I should file an issue
I've searched for pewpew in homebrew repository, but haven't found it.

I know, that pewpew is available as a release, but I think it would be more convenient to upload it to package repositories, such as homebrew, apt, aur and others.

It's a great tool and it would be great if it's installation could be even more straightforward

dns-prefetch does not work when ports are specified

How do you create the issue, and how reproducible is it? (show the full command)

% ./pewpew stress --dns-prefetch 'http://production-something-003.mgmt.pg.net.local:8000/blah'
Error: failed to create request with target configuration: failed to prefetch host production-something-003.mgmt.pg.net.local:8000
Usage:
  pewpew stress URL... [flags]

Yet works fine without --dns-prefetch

What version of pewpew are you running?

0.3.2

Did you compile pewpew yourself, or use a prebuilt version?

Prebuilt release from GitHub.

Staggered/delayed requests

Currently, pewpew immediately bombs the specified URL with requests. With just a few concurrent requests this is somewhat undesirable - would be nice if it were possible to stagger request threads, i.e. given 5 connections and a delay of 5 seconds, also allow 1 second before each run is started for a gradual ramp-up.

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.