Skip to content
A better load generator for locust, written in golang
Branch: master
Clone or download
Latest commit 4ccbb1e Jun 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Jun 22, 2018
docs add support for standalone mode and custom outputs. Jun 6, 2019
examples add support for standalone mode and custom outputs. Jun 6, 2019
.gitignore add docs May 30, 2019
.travis.yml change minimum supported go version to 1.8 Jun 6, 2019
LICENSE it is 2019 Jan 15, 2019
README.md add readthedocs.io link May 30, 2019
README_CN.md add readthedocs.io link May 30, 2019
boomer.go FIX: addOutput errors when it's called before Run Jun 13, 2019
boomer_test.go add tests for the module level Run method Jun 18, 2019
client.go FIX: don't exit Jun 18, 2019
client_czmq.go FIX: don't exit Jun 18, 2019
client_gomq.go FIX: don't exit Jun 18, 2019
client_gomq_test.go change to zeromq's dealer socket Feb 19, 2019
dummy.py first commit Feb 18, 2016
legacy.go Expose the Boomer type and the RateLimiter interface Mar 11, 2019
legacy_test.go add support for standalone mode and custom outputs. Jun 6, 2019
message.go don't exit, just log the error Nov 21, 2018
message_test.go don't exit, just log the error Nov 21, 2018
output.go add tests for output Jun 14, 2019
output_test.go add tests for output Jun 14, 2019
prometheus_exporter.py FIX: keep compatible with locust Jun 14, 2019
ratelimiter.go Expose the Boomer type and the RateLimiter interface Mar 11, 2019
ratelimiter_test.go add tests Mar 13, 2019
runner.go FIX: don't exit Jun 18, 2019
runner_test.go FIX: duplicate close Jun 6, 2019
stats.go FIX: keep compatible with locust Jun 14, 2019
stats_test.go FIX: keep compatible with locust Jun 14, 2019
task.go add support for standalone mode and custom outputs. Jun 6, 2019
utils.go FIX: fd leakage Jun 11, 2019
utils_test.go return error instead of exiting the program Jun 11, 2019

README.md

boomer Build Status Go Report Card Coverage Status Documentation Status

Links

Description

Boomer is a better load generator for locust, written in golang. It can spawn thousands of goroutines to run your code concurrently.

It will listen and report to the locust master automatically, your test results will be displayed on the master's web UI.

Use it as a library, not a general-purpose benchmarking tool.

Install

go get github.com/myzhan/boomer

Build

Boomer use gomq by default, which is a pure Go implementation of the ZeroMQ protocol.

Because of the instability of gomq, you can switch to goczmq.

# use gomq
go build -o a.out main.go
# use goczmq
go build -tags 'goczmq' -o a.out main.go

If you fail to compile boomer with gomq, try to update gomq first.

go get -u github.com/zeromq/gomq

Examples(main.go)

This is a example of boomer's API. You can find more in the "examples" directory.

package main

import "time"
import "github.com/myzhan/boomer"

func foo(){
    start := time.Now()
    time.Sleep(100 * time.Millisecond)
    elapsed := time.Since(start)

    /*
    Report your test result as a success, if you write it in locust, it will looks like this
    events.request_success.fire(request_type="http", name="foo", response_time=100, response_length=10)
    */
    boomer.RecordSuccess("http", "foo", elapsed.Nanoseconds()/int64(time.Millisecond), int64(10))
}

func bar(){
    start := time.Now()
    time.Sleep(100 * time.Millisecond)
    elapsed := time.Since(start)

    /*
    Report your test result as a failure, if you write it in locust, it will looks like this
    events.request_failure.fire(request_type="udp", name="bar", response_time=100, exception=Exception("udp error"))
    */
    boomer.RecordFailure("udp", "bar", elapsed.Nanoseconds()/int64(time.Millisecond), "udp error")
}

func main(){
    task1 := &boomer.Task{
        Name: "foo",
        // The weight is used to distribute goroutines over multiple tasks.
        Weight: 10,
        Fn: foo,
    }

    task2 := &boomer.Task{
        Name: "bar",
        Weight: 20,
        Fn: bar,
    }

    boomer.Run(task1, task2)
}

Run

For debug purpose, you can run tasks without connecting to the master.

go build -o a.out main.go
./a.out --run-tasks foo,bar

Otherwise, start the master using the included dummy.py.

locust --master -f dummy.py

--max-rps means the max count that all the Task.Fn can be called in one second.

The result may be misleading if you call boomer.RecordSuccess() more than once in Task.Fn.

go build -o a.out main.go
./a.out --max-rps 10000

If you want the RPS increase from zero to max-rps or infinity.

go build -o a.out main.go
# The default interval is 1 second
./a.out --request-increase-rate 10
# Change the interval to 1 minute
# Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h"
./a.out --request-increase-rate 10/1m

So far, dummy.py is necessary when starting a master, because locust needs such a file.

Don't worry, dummy.py has nothing to do with your test.

Profiling

You may think there are bottlenecks in your load generator, don't hesitate to do profiling.

Both CPU and memory profiling are supported.

It's not suggested to run CPU profiling and memory profiling at the same time.

CPU Profiling

# 1. run locust master.
# 2. run boomer with cpu profiling for 30 seconds.
$ go run main.go -cpu-profile cpu.pprof -cpu-profile-duration 30s
# 3. start test in the WebUI.
# 4. run pprof.
$ go tool pprof cpu.pprof
Type: cpu
Time: Nov 14, 2018 at 8:04pm (CST)
Duration: 30.17s, Total samples = 12.07s (40.01%)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) web

Memory Profiling

# 1. run locust master.
# 2. run boomer with memory profiling for 30 seconds.
$ go run main.go -mem-profile mem.pprof -mem-profile-duration 30s
# 3. start test in the WebUI.
# 4. run pprof and try 'go tool pprof --help' to learn more.
$ go tool pprof -alloc_space mem.pprof
Type: alloc_space
Time: Nov 14, 2018 at 8:26pm (CST)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top

Contributing

If you are enjoying boomer and willing to add new features to it, you are welcome.

Also, good examples are welcome!!!

License

Open source licensed under the MIT license (see LICENSE file for details).

You can’t perform that action at this time.