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 consistent hashing InputMatcher #14782

Closed
snowp opened this issue Jan 21, 2021 · 2 comments · Fixed by #14875
Closed

Add consistent hashing InputMatcher #14782

snowp opened this issue Jan 21, 2021 · 2 comments · Fixed by #14875
Labels
area/matching enhancement Feature requests. Not bugs or questions. help wanted Needs help!

Comments

@snowp
Copy link
Contributor

snowp commented Jan 21, 2021

Tracks adding a simple InputMatcher that takes a configurable threshold and will consistently hash the input string, matching if the resulting hash value is above the configured threshold:

match = (hash(input) % 100) > threshold

This would allow users to configure a match rule that will consistently match X% of requests based on a random input string (e.g. a tracing header).

@snowp snowp added enhancement Feature requests. Not bugs or questions. help wanted Needs help! area/matching labels Jan 21, 2021
@kailun-qin
Copy link
Contributor

kailun-qin commented Jan 22, 2021

@snowp
At which level would you prefer this matching should be added to? Supposing there are actually 3 opts:

  1. extending as a separate match logic for SinglePredicate InputMatcher;
  2. extending as a new match rule for StringMatcher;
  3. adding as a new ConsistentHashMatcher type.

Thanks.

@snowp
Copy link
Contributor Author

snowp commented Jan 28, 2021

I would add this as a CustomMatcher extension for use within the SinglePredicate. I don't recall off the top of my head whether we've wired up the extension factory logic here, so that might be part of it

htuch pushed a commit that referenced this issue Mar 8, 2021
This introduces a new matcher that allows matching on an input value by
computing a hash value and matching if the value % (configured value) is
greater than a configured threshold. This is useful in being able to
define match criteria that should match for a certain % of input values
in a way that is consistent between independent Envoy instances (e.g. it
does not rely on a random input).

Risk Level: Low, new extension
Testing: UTs
Docs Changes: Inline proto docs
Release Notes: n/a
Platform Specific Features: n/a
Fixes #14782

Signed-off-by: Snow Pettersen <snowp@lyft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/matching enhancement Feature requests. Not bugs or questions. help wanted Needs help!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants