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

[scheduler] Admission rotation window + improve hash distribution #865

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

fwbrasil
Copy link
Collaborator

The current mechanism will always penalize the same ids. This PR introduces a time-based window mechanism to rotate which IDs are rejected over time. I've also added a multiplication with a large prime to improve the hash distribution in case the incoming IDs aren't well distributed.

@@ -76,9 +91,12 @@ final class Admission(
schedule: Task => Unit,
nowMillis: LongSupplier,
timer: InternalTimer,
config: Config = Admission.defaultConfig
config: Config = Admission.defaultConfig,
rotationWindow: Duration = Flag("admission.rotationWindowMinutes", 60).minutes
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about 5 minutes? Any reason the scheduler would need such a long window?

Copy link
Collaborator Author

@fwbrasil fwbrasil Nov 26, 2024

Choose a reason for hiding this comment

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

It's not much about the scheduler itself. On each new rotation window, a new set of ids are accepted. If a system is under pressure, the shift in incoming load to a new set of users can increase the pressure on shared resources. For example, data might need to be loaded from databases to caches and cache evictions can compound the pressure. The longer window favors stability. The goal is to avoid the same set of users always being penalized across all outages, not necessarily provide user-level fairness during a specific outage. It's always possible to tune the config, though.

@fwbrasil fwbrasil merged commit e996c17 into main Nov 26, 2024
3 checks passed
@fwbrasil fwbrasil deleted the admission-ratation branch November 26, 2024 07:18
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