A simple http filter that can randomly drop requests
We have recently developed an http filter called random_drop and used it in our online project. It is currently working well. So we want to contribute it to the community.
What does this filter do?
Randomly discard requests based on the configured percentage.
Under what circumstances do we need this filter?
When a non-core service fails, we need to discard some or all of the traffic sent to it to ensure the availability of the core service.
What is the difference between rate limit filter and circuit breaker?
-
When using local rate limit, we need to calculate the traffic allocated to each Envoy instance, sometimes this is not possible.
-
When using global rate limit, we need to introduce a rate limit server, which increases the complexity, and the rate limit server may become a hot spot.
-
The circuit breaker cannot achieve per-route limit.
We already have the concept of "maintenance mode" which covers this. I would rather just enhance that functionality if it doesn't cover what is needed.
We already have the concept of "maintenance mode" which covers this. I would rather just enhance that functionality if it doesn't cover what is needed.
The cluster maintenance mode does cover most of our scenarios, except that different path(or gRPC method) in the same cluster might have different rejection percentage. Maybe this is not a very general requirement. So I am not sure if it is worthwhile to extend the maintenance mode to support path level or something like that. What do you think? @mattklein123
I think it's fair that if you want per-route maintenance mode the existing cluster maintenance mode does not work well. Can you describe a bit more about how this is going to work? Will it use runtime? Will it rely on fixed config you deliver using ECDS? Etc. Could it use the new matching framework that @snowp developed? Etc.
Our implementation is quite simple. Similar to the cluster maintenance mode, we only use the runtime, including an enable runtime as a global switch, and a set of runtimes in the form of "degradation.random_drop.<cluster_name>.<path>". In particular, when the path in a runtime is /, it works exactly the same as the cluster maintenance mode. The config looks like:
message Config {
config.core.v3.RuntimeFeatureFlag enabled = 1;
string runtime_key_prefix = 2; // degradation.random_drop
}
PS: I didn’t know much about the matching framework before. I read the related documents today. It is awesome, and I think the framework can make this filter more flexible. For example, we can add a header match and the header value is the drop percentage. This is very useful when RTDS is unavailable.
Is it different from fault filter? The fault filter can also reject requests based on the configured ratio. 🤔 The fault filter also provides very flexible matching.
I agree that technically the runtime config can work, but in the spirit of trying to consolidate matching with "the way forward" I would suggest we implement this using the generic matching framework which then decides whether to drop or not. cc @snowp who can take a quick look, provide docs, and some guidance on whether he thinks that would be a good fit for this type of functionality.
Yeah I think we can put all of the runtime, path, etc. checking in a match tree, then the resulting filter would be super simple (perhaps even implementable via the fault filter as suggested?)
We could for example have a data input that acts on the HTTP headers to construct the runtime key to read, then reads this from runtime to produce the value to match on. A % based matcher could then be used to implement percentage based matching, or a trivial string matcher (against true) if we want this to just act like a runtime feature flag.
I think adding this functionality would make it a lot easier to add runtime flags to existing filters without having to add explicit configuration to each filter.
I think adding this functionality would make it a lot easier to add runtime flags to existing filters without having to add explicit configuration to each filter.
+1 this is what I was hoping for.
Thank you all for your answers and suggestions. I'll start with a detailed look at the amazing matching framework!
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.