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

reverseproxy: Optimize the base case for least_conn policy #5487

Merged
merged 1 commit into from
May 6, 2023

Conversation

francislavoie
Copy link
Member

When only a single request has the least amount of requests, there's no need to compute a random number, because the modulo of 1 will always be 0 anyways.

@francislavoie francislavoie requested a review from mholt April 12, 2023 12:02
@francislavoie francislavoie added the optimization 📉 Performance or cost improvements label Apr 12, 2023
@francislavoie francislavoie added this to the v2.7.0 milestone Apr 12, 2023
@francislavoie
Copy link
Member Author

francislavoie commented Apr 12, 2023

I just noticed random_choose also uses similar leastRequests() logic and was also missing the base case of one option. Added a condition for that too.

When only a single request has the least amount of requests, there's no need to compute a random number, because the modulo of 1 will always be 0 anyways.
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Cool, let's save those cycles! Thanks!

@mholt mholt merged commit b19946f into master May 6, 2023
@mholt mholt deleted the optimize-leastconn branch May 6, 2023 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization 📉 Performance or cost improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants