myzhan / boomer

A better load generator for locust, written in golang.
MIT License
1.18k stars 242 forks source link

Unexpected RPS #23

Closed ghost closed 6 years ago

ghost commented 6 years ago

I am testing out your driver under this project. I am running the local Go server and setting a 1000 users to simulate with a hatch rate of 1. The request rate is highly fluctuating. I have tested a local Go server with Vegeta at ~30,000 RPS. I would also expect the request rate to increment up to 1000.

myzhan commented 6 years ago

You are using golang's http client the wrong way. Try this

package main

import (
        "log"
        "net/http"
        "strconv"

        "github.com/myzhan/boomer"
)

func urlBash() {
        start := boomer.Now()

        localServer := "http://localhost:8080"
        response, err := http.Get(localServer)
        if err != nil {
                log.Fatalf("%v\n", err)
        }
        defer response.Body.Close()

        elapsed := boomer.Now() - start

        if response.StatusCode == 200 {
                boomer.Events.Publish("request_success", "http", "urlBash", elapsed, response.ContentLength)
        } else {
                boomer.Events.Publish("request_failure", "http", "urlBash", elapsed, strconv.Itoa(response.StatusCode))
        }

}

func main() {

        task := &boomer.Task{
                Name: "urlBash",
                Fn:   urlBash,
        }
        http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = 2000

        boomer.Run(task)
}
myzhan commented 6 years ago

Use keep-alive connections.

ghost commented 6 years ago

Thanks. I should have read your http example more thoroughly. However, with a 1000 users at a hatch rate of 1, I am getting ~25,000 RPS and no incremental hatch rate.

myzhan commented 6 years ago

I think if you use 10 users, you will get the same RPS(~25,000). You should tune your test environment.

Running the same codes in my Macbook Pro, I got this result.

image

myzhan commented 6 years ago

Thank you, I found a little bug while testing your code.

https://github.com/myzhan/boomer/commit/6dad7477c73f7c0f79fc0768463a0c3d84519738

ghost commented 6 years ago

No - thank you.

ghost commented 6 years ago

You should tune your test environment

Just put a delay in - aaahhhhhh. Thanks.