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

Resolve Split-Brain of WatchDocument with Stateful Session Affinity #903

Open
krapie opened this issue Jun 18, 2024 · 0 comments
Open

Resolve Split-Brain of WatchDocument with Stateful Session Affinity #903

krapie opened this issue Jun 18, 2024 · 0 comments
Labels
discussion 💭 Need to be discussed enhancement 🌟 New feature or request

Comments

@krapie
Copy link
Member

krapie commented Jun 18, 2024

Description:

Introduce stateful session affinity in yorkie cluster to resolve Split-Brain of WatchDocument. In other words, implementing session affinity to enable session routing with strong affinity over current ring hash with weak affinity.

Few months ago, envoy and istio have implemented stateful session affinity to resolve the same issue that we have. Below is how this stateful session affinity works in envoy & istio.

  • If the session key x-session-key is empty in the request, envoy routes based on the existing LB policy of ring hash and returns x-session-key in the response with a base64 encoded value of the ip:port of the routed server to the client.
  • Then, the client will set x-session-key header in the subsequent requests, allowing envoy to override the existing LB policy and route the request based on the decoded value ip:port.

One thing to keep in mind is that when backend host set changes, new client trying to attach to the document might be routed to different backend due to changes of ring hash calculation, similar to previous split-brain issue. But this time we know where the client should route to by x-session-key, so we can resolve this issue by storing x-session-key in "session store" like Redis or etcd, and provide the client on initialization (probably in AttachDocument).

To conclude, it's going to be a combination of both stateful session and ring hash. Stateful session will ensuring clients to connect to the same server on any situations. Ring hash will distribute the workloads(sessions) evenly with minimum disruption on backend host set changes.

Below are resources related to this issue.

Why:

By implementing session affinity, even after changes in the backend servers, clients will be routed to the same server for collaboration on shared documents. It ensures consistency for clients connecting to the same document.

This will completely resolve decreased sync sensitivity between peers caused by WatchDocument's split-brain issue.

@krapie krapie added the enhancement 🌟 New feature or request label Jun 18, 2024
@hackerwins hackerwins added the discussion 💭 Need to be discussed label Jun 18, 2024
@hackerwins hackerwins changed the title Introduce Stateful Session Affinity in Yorkie Cluster Resolving Split-Brain of WatchDocument Jun 18, 2024
@krapie krapie changed the title Resolving Split-Brain of WatchDocument Resolve Split-Brain of WatchDocument Jun 18, 2024
@krapie krapie changed the title Resolve Split-Brain of WatchDocument Resolve Split-Brain of WatchDocument with Stateful Session Affinity Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion 💭 Need to be discussed enhancement 🌟 New feature or request
Projects
Status: Backlog
Status: Todo
Development

No branches or pull requests

2 participants