-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
ConsistentHashLB: Hash based on request path/url #11554
Comments
@berstend can you pls guide me in explaining more in it. What I found out in envoy documentation here "https://www.envoyproxy.io/docs/envoy/v1.9.0/intro/arch_overview/load_balancing/load_balancers" that it doesn't provide such load-balancing functionality. Do we need something like this : https://www.haproxy.com/blog/haproxys-load-balancing-algorithm-for-static-content-delivery-with-varnish/ hashing the whole url, including the query string
Query string parameter hash
Do we need need to implement such load-balancing at envoy's end ? |
@murarisumit thanks for your followup questions. Unfortunately I'm not too familiar with the envoy proxy internals (yet), to know with certainty wether or not envoy supports url based load balancing currently. Let me instead lay out my use-case in more detail:
As a developer using istio I wish to use the URL (or path) as the ring key for load balancing/sticky sessions. Currently that doesn't seem possible. In my scenario it's not too relevant if query strings are part of the hash or not. My current workaround: Add a Cloudflare Worker which will add the URL to the request headers: addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* Add `x-url` header to fetch request
* @param {Request} request
*/
async function handleRequest(request) {
const headers = new Headers(request.headers)
headers.set('x-url', request.url)
return fetch(request, { headers })
} Use the apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: {{ $.Release.Name }}-dest-{{ $versionId }}
spec:
host: {{ $.Release.Name }}
trafficPolicy:
loadBalancer:
consistentHash:
httpHeaderName: x-url
subsets:
- name: version-{{ $versionId }}
labels:
app: {{ $.Release.Name }}
version: {{ $versionId }} This works as expected (sticky sessions based on request URL) but has a dependency on having Cloudflare in front of the cluster. Would love to simplify this and have istio allow me to use the request url directly. Thanks! |
This envoy issue might be related: envoyproxy/envoy#2436 (found through the more specifically related envoyproxy/envoy#2334). |
This issue has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed in the next 30 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had activity in the last month and a half. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions. |
Is it possible to get this re-opened @rlenglet ? |
🚧 This issue or pull request has been closed due to not having had activity in the last 195 days. If you feel this issue or pull request deserves attention, please reopen the issue. Please see this wiki page for more information. Thank you for your contributions. Created by the issue and PR lifecycle manager. |
In case you want to have consistent hash-based load balancing (i.e. for "sharding" purposes) that is only dependent on the request's path (and query string), you can use a spec:
host: {{ $.Release.Name }}
trafficPolicy:
loadBalancer:
consistentHash:
httpHeaderName: ':path' This uses the pseudo-header |
@kaiburjack Many thanks for your input, could you provide some examples, such that I can see whether this would be well-suited for our use case? Specifically, I do not quite understand how I would have to understand |
@junoriosity |
This is super neat. I wonder if there's another similar pseudo-header that only takes into account the path and not the query parameters. I have requests of form As mentioned above, I could always set up a reverse proxy to add a custom header (ignoring the query params). But wondering if there is an Envoy hack to accomplish the same. EDIT - doesn't seem like there is, unfortunately. |
I have a use-case where it'd be amazing to use the consistent hash-based load balancer based on the path (or URL) of the request.
Unfortunately it seems like I cannot use
httpHeaderName
to extract the path or request url.Or is there a way to do this currently that I missed?
Thanks!
The text was updated successfully, but these errors were encountered: