Skip to content

[ENH] Multi-dimensional admission control. #3579

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

Merged
merged 7 commits into from
Jan 28, 2025
Merged

[ENH] Multi-dimensional admission control. #3579

merged 7 commits into from
Jan 28, 2025

Conversation

rescrv
Copy link
Contributor

@rescrv rescrv commented Jan 28, 2025

This PR creates a multi-dimensional "scorecard" that tags traffic and a circuit breaker that rejects excess traffic.

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

rules: Vec<Rule>,
estimate_thread_count: usize,
) -> Self {
assert!(estimate_thread_count > 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NonZeroUsize.

#[test]
fn basics() {
let metrics = TestMetrics::default();
// NOTE(rescrv): We diverge from the upstream behavior here. If a tag doesn't match a
Copy link
Contributor

Choose a reason for hiding this comment

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

can we clarify what upstream is please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

request_timeout_ms: 60000
circuit_breaker:
requests: 1
Copy link
Contributor

Choose a reason for hiding this comment

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

should the default be higher?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the default to make it not enabled by default.

}

impl Frontend {
pub fn new(sysdb_client: Box<sysdb::SysDb>) -> Self {
let scorecard_enabled = Arc::new(AtomicBool::new(false));
let scorecard = Arc::new(Scorecard::new(&(), vec![], 128));
Copy link
Contributor

Choose a reason for hiding this comment

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

should the thread count be provided by config or inferred from the env?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

128 is sufficient for everything we need. I think inferring it would do us strictly worse if we get it wrong as it's an upper bound.

@rescrv rescrv merged commit 60806f6 into main Jan 28, 2025
90 checks passed
@rescrv rescrv deleted the rescrv/mdac branch January 28, 2025 19:11
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