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

[FEATURE REQUEST] Support node locality routing hints #1821

Open
mccheah opened this issue Nov 16, 2022 · 2 comments
Open

[FEATURE REQUEST] Support node locality routing hints #1821

mccheah opened this issue Nov 16, 2022 · 2 comments

Comments

@mccheah
Copy link

mccheah commented Nov 16, 2022

What happened?

In distributed environments, sometimes it is desirable for multiple calls in a sequence to predictably route to a given node. This seems to have similarities to the request in #1000 and other places, so feel free to reroute this ask to that ticket or others that might be similar.

The use case is as follows: Suppose we have a client web browser, and two clustered servers, D with nodes D1, D2 ... Dk, and H with nodes H1, H2 ... Hn. An operation on the browser executes two requests against D, each of which routes to a request against H. The nodes of H each hold a local cache.

In this environment, currently, it is very hard to achieve optimal cache locality on H. For example, consider two requests R1 and R2. R1 against D might hit node D1, which routes to node H2. But the second request R2 reaching D, if it were to also route to node H2, would achieve cache locality - but suppose this request instead routes to D2, and then routes to H1 - this would cause a cache miss and degrade performance.

The current workaround would be to use per-node-clients, and have the web browser pass in a stable sort of session token to D, and D can pick a stable instance of H to route to. Using per-node-clients is not ideal, because in the process we end up losing the built-in failover / retry behavior that Dialogue offers.

What did you want to happen?

Introduce the construct of a "node locality hint", which is inspired by Elasticsearch's similar notion of node locality preference hinting: https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-search.html#search-preference.

Support a new type of client - name is debatable, but let's call it LocalityHintClientFactory / LocalityHintClient<T>. Have an API that supports conversion from LocalityHintClient<T> to T that accepts a hint key, which is used to seed the round-robin rotation in the underlying client (probably just hash the key, then modulo number of nodes, then sort the nodes and index into the sorted list). Thus multiple calls to the client that specify the same hint key should first attempt to route to the same node, even across a cluster.

@mccheah mccheah changed the title [FEATURE REQUEST] Support node locality routing preference [FEATURE REQUEST] Support node locality routing hints Nov 16, 2022
@jkozlowski
Copy link
Contributor

Have you seen this?

public StickyChannelFactory2 getStickyChannels2(String serviceName) {

@henryptung
Copy link

henryptung commented Nov 17, 2022

Hey @jkozlowski, for some more context:

  • The goal isn't to make a single request flow stick with a given mirror, but rather to make all requests which map to a particular cache key (e.g. a particular Horizon subset ID, so that the same set of objects can be aggregated repeatedly in different ways) stick with/prefer a specific mirror.
  • Even if we e.g. cached the sticky channel by user in Dispatch, this would still not guarantee that:
    • Requests with the same key on a different Dispatch don't get routed differently
    • Horizon internally routes traffic for that key to the same shard mirror (Horizon is also sharded, so different shards will talk to each other for some operations)

It feels like the existing sticky mechanisms aren't sufficient for those reasons, but suggestions are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants