-
Notifications
You must be signed in to change notification settings - Fork 621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rideshare example for integrating with k6 #3648
Conversation
for i := 0; i < vus; i++ { | ||
doneChs[i] = make(chan struct{}) | ||
|
||
go func(done <-chan struct{}) { | ||
for { | ||
select { | ||
case <-done: | ||
return | ||
default: | ||
err := sendThrottledRequest(context.Background(), url, sleep, jitter) | ||
if err != nil { | ||
log.Printf("failed to send request to %s: %v", url, err) | ||
} | ||
} | ||
} | ||
}(doneChs[i]) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main continuous load test loop (different from a k6 load test). This is slightly altered from the original rideshare example. The original was aware of each replica and would try evenly distribute requests across all of them.
Since we now put all the replicas behind a nginx proxy, the load test program does not need to try evenly balance load across all of them. Now we spin up the defined number of VUs and have the make random endpoint requests to the proxy itself.
examples/language-sdk-instrumentation/golang-push/rideshare-k6/main.go
Outdated
Show resolved
Hide resolved
examples/language-sdk-instrumentation/golang-push/rideshare-k6/README.md
Outdated
Show resolved
Hide resolved
examples/language-sdk-instrumentation/golang-push/rideshare-k6/README.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This is more or less a copy of the existing Go Rideshare example, but now with k6 middleware added to the handlers.
To make the load test script easier to understand, I opted to add an nginx proxy in front of the ride share services. This means the k6 load test script can make requests to a single endpoint instead of having to add extra logic to evenly distribute load across all the services.
cc @Rperry2174