Skip to content
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

Merged
merged 4 commits into from
Oct 28, 2024
Merged

Conversation

bryanhuhta
Copy link
Contributor

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

@bryanhuhta bryanhuhta self-assigned this Oct 24, 2024
@bryanhuhta bryanhuhta requested a review from a team as a code owner October 24, 2024 22:18
Comment on lines +84 to +100
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])
}
Copy link
Contributor Author

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.

Copy link
Contributor

@marcsanmi marcsanmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@bryanhuhta bryanhuhta enabled auto-merge (squash) October 28, 2024 16:44
@bryanhuhta bryanhuhta merged commit ba4b92d into main Oct 28, 2024
18 checks passed
@bryanhuhta bryanhuhta deleted the k6-rideshare-example branch October 28, 2024 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants