-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
stateful session persistence #16698
Comments
cc @alyssawilk |
In general, it is not complicated and does not require much new code. I am not sure but this may be can close #7218. |
Add a doc to describe more detail and some possible solutions. |
@alyssawilk @mattklein123 Is this plan feasible for #7218 |
for cookies, can you comment where this doesn't meet your needs? |
@alyssawilk The most important reason is that no matter what hash policy is used, the existing session persistence is stateless. In the current solution, the cookie generated by Envoy does not directly save the upstream host information. A suitable host is obtained according to the algorithm based on the value calculated by the hash. The requirement in #7218 is actually a good example. When host x is marked as draining or degraded or unhealthy, for the existing session requests, we hope that they will still be routed to host x. If we have the ability to maintain stateful session persistence, and for each session, save the relevant host information, then we can do this. |
so at some point if a host is draining it's going to go away. It sounds like what you really want here is a period where no new "sticky" sessions are assigned, but sessions already sticky to an upstream will be routed there? You say on the doc that maglev might meet your needs if only you could route while draining, but I don't think either of your design options include routing to a host while it's draining, which I don't think your cookie solution would necessarily do either. That said, encoding ip:port of backend in cookies and using them for direct routing is a pretty common method of LB, and if you want to implement that I think it would be a useful addition to Envoy. |
Yes.
The draining host is special. Because it has been removed from the hosts set of the cluster, we may need to think more about it. But unhealthy host and degraded host can use the cookie scheme to maintain the existing sticky session.
I am happy to implement it. |
Ok reposting some of the stuff shared with @wbpcode offline, since it might be useful for future cases of custom load balancing. We've used two methods for achieving something similar to what could be called stateful session persistence. Case 1: Case 2: Happy to expand more on any of these details. [0] https://medium.com/pinterest-engineering/simplifying-web-deploys-19244fe13737 |
Reposting some replies to @rgs1 so that people who want to learn about this work can get more information.
But l think the problems In essence, subset lb is still matching routing rules and then selecting host. (By setting clever matching rules, you can achieve a result similar to stateful session sticky in some scenarios, but I think this way of using it is too complicated for persisting the session, and it only covers some of the scenarios) The stateful session sticky is to record the result of the first match, and then directly route to the corresponding host. And it is completely independent of the load balancing algorithm. Any load balancing algorithm can obtain this property. More detailed doc: https://docs.google.com/document/d/1IU4b76AgOXijNa4sew1gfBfSiOMbZNiEt5Dhis8QpYg/edit?usp=sharing Similar function in other proxy: https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/#enabling-session-persistence |
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. |
working |
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. |
working |
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. |
working |
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. |
Http session persistence is achieved through hash-based (consistent hash algorithm) load balancing. When the state of the backend servers change (new server is added, existing server is deleted, server state is updated, etc.) it breaks the session persistence result.
Is it possible to consider adding a cookie-based stateful session persistence? When this feature is turned on, the host id or something is added to the cookie. When new requests arrive, the corresponding host is resolved from the cookie and passed to the LoadBalancer via
Upstream::LoadBalancerContext
. The LoadBalancer can return this host first, if possible.The text was updated successfully, but these errors were encountered: