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

Randomize --connect-to if multiple matching options #695

Merged
merged 3 commits into from
Feb 11, 2025

Conversation

thomasgl-orange
Copy link
Contributor

Here is a PR to better handle this:

oha \
  --connect-to something.com:443:backend1.fqdn:8443 \
  --connect-to something.com:443:backend2.fqdn:8443 \
  https://something.com

In this case, a random choice will be made for each request between backend1.fqdn:8443 and backend2.fqdn:8443. Where as currently, while the syntax is not rejected, it's always the same target which would be picked.

My use case is being able to bypass an actual TCP load-balancer in front of the backend servers, just to check it doesn't have a significant impact on the overall performances.

I've seen that DNS resolution already makes some similar random choice per-request in case several IP are returned for the domain. I guess I could use that (with some local dnsmasq entries) for my use case, but this --connect-to approach sounds more intuitive.

The second commit is a test case with 100 requests to spread across two servers, listening on two local ports. It checks that both receive at least some requests, and that the total number of requests received is indeed 100.

Copy link
Owner

@hatoo hatoo left a comment

Choose a reason for hiding this comment

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

Please fix clippy warning.
Others are good!

@thomasgl-orange
Copy link
Contributor Author

Thanks @hatoo for the quick review and reply, much appreciated!
I've just pushed 1bb9e1b to fix the clippy warning.

@hatoo hatoo merged commit 3c74994 into hatoo:master Feb 11, 2025
17 of 18 checks passed
@hatoo
Copy link
Owner

hatoo commented Feb 11, 2025

thank you!

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.

2 participants