A better load generator for locust, written in golang
Switch branches/tags
Nothing to show
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Jun 22, 2018
examples add boomer-cli as an example Nov 15, 2018
.gitignore add doc for profiling Nov 14, 2018
.travis.yml add codecov Nov 5, 2018
LICENSE update license Jan 10, 2018
README.md it may be misleading Nov 19, 2018
README_CN.md it may be misleading Nov 19, 2018
boomer.go move rate limite out of runner Dec 12, 2018
boomer_test.go FIX: prevent goroutine leakage in defaultStats Nov 16, 2018
client.go refactor client and remove global channels Nov 16, 2018
client_czmq.go refactor client and remove global channels Nov 16, 2018
client_gomq.go don't exit, just log the error Nov 21, 2018
client_gomq_test.go don't exit, just log the error Nov 21, 2018
dummy.py first commit Feb 18, 2016
events.go refactor stats to reduce global variables Nov 15, 2018
events_test.go refactor stats to reduce global variables Nov 15, 2018
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
ratelimiter.go move rate limite out of runner Dec 12, 2018
ratelimiter_test.go move rate limite out of runner Dec 12, 2018
runner.go move rate limite out of runner Dec 12, 2018
runner_test.go move rate limite out of runner Dec 12, 2018
stats.go refactor stats to reduce global variables Nov 15, 2018
stats_test.go add benchmark for hotspots Nov 30, 2018
utils.go FIX: typo Nov 15, 2017
utils_test.go add test for Now() Nov 14, 2018

README.md

boomer Build Status Go Report Card Coverage 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.

Install

go get github.com/myzhan/boomer

Zeromq support

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

Becase 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 fisrt.

go get -u github.com/zeromq/gomq

Examples(main.go)

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

package main


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


func foo(){

    start := boomer.Now()
    time.Sleep(100 * time.Millisecond)
    elapsed := boomer.Now() - 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.Events.Publish("request_success", "http", "foo", elapsed, int64(10))
}


func bar(){

    start := boomer.Now()
    time.Sleep(100 * time.Millisecond)
    elapsed := boomer.Now() - 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.Events.Publish("request_failure", "udp", "bar", elapsed, "udp error")
}


func main(){

    task1 := &boomer.Task{
        Name: "foo",
        Weight: 10,
        Fn: foo,
    }

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

    boomer.Run(task1, task2)

}

Usage

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

--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.Events.Publish("request_success") 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).