-
Notifications
You must be signed in to change notification settings - Fork 228
WIP: Document hash-based routing #569
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
base: master
Are you sure you want to change the base?
Conversation
peanball
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some wording, some questions.
hash-based-routing.html.md.erb
Outdated
|
|
||
| - **Configurable via Per-Route Options**: Easily set up Hash-Based Routing using application route options | ||
| - **Consistent Hashing**: Implements the Maglev consistent hashing algorithm as outlined in the paper "Maglev: A Fast and Reliable Software Network Load Balancer" (https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf) | ||
| - **Minimal Rehashing**: Uses the Maglev lookup table to map application instances by hash, minimizing the need to recalculate the entire table when instances are added or removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the recalculation is not the expensive part. The really expensive part is the resulting shift of specific hashes to other instances. This rehashing minimization makes sure that happens as little as possible and keeps the "allocation" of hash values to their instances as stable as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. I did not like the word recalculation either, I wanted to say the same what you mentioned.
Maybe:
**Minimal Rehashing**: Uses the Maglev lookup table to map application instances by hash, ensuring that hash positions are shifted to other instances as little as possible when application instances are added or removed."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds great!
|
|
||
| Hash-Based Routing implements a clear precedence hierarchy: | ||
|
|
||
| 1. **Sticky Sessions**: First checks if a sticky session is used and the sticky session endpoint is available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the sticky session counted towards the balance / in-flight requests or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All in-flight requests will be counted (incl. sticky session requests). It happens via {RoundRobin Iterater | HashBased Iterator | LeastConnection Iterator}.PreRequest logic
| While Session Affinity offers a solution for maintaining session consistency, it poses scalability challenges, as Session Affinity is confined to a single instance. It increases the risk that large customers could be routed to the same instance by chance. On the other hand, enabling Session Affinity requires additional implementation effort on the application side to return a sticky session cookie in responses. | ||
|
|
||
| In contrast, Hash-Based Routing provides a more scalable and balanced approach by consistently distributing requests based on a hash of a specific HTTP header value (e.g., `X-Resource-ID` or `Tenant-ID`). This hash value determines the appropriate application instance for each request, ensuring that requests with the same hash are consistently routed to the same instance, but might be routed to another predetermined instance when the current one is saturated (find more about Handling imbalanced loads below). | ||
|
|
||
| This makes it especially suitable for applications requiring high scalability and performance, such as microservices architectures or multi-tenant applications, when dealing with limited or memory-intensive resources in backend services. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These paragraphs are very wordy and a bit meandering. LLM?
Either way, the main point is:
Session affinity works on session level. Heavy users may end up on the same instance and through session affinity pin to it, thus overloading it. Identifying sessions for web applications is usually done via session cookie and does not pose too much implementation burden. CF only supports a single cookie name however, defaulting to JSESSIONID.
With hash based routing, identifiers other than the session ID can be used, and spill-over to other instances is possible with the balance factor (see next section).
Co-authored-by: Alexander Lais <Alexander.lais@me.com>
hoffmaen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rephrasing key features
hash-based-routing.html.md.erb
Outdated
|
|
||
| ## <a id="key-features"></a> Key Features | ||
|
|
||
| - **Configurable via Per-Route Options**: Easily set up Hash-Based Routing using application route options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a link to per-route-options documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - **Configurable via Per-Route Options**: Easily set up Hash-Based Routing using application route options | |
| - **Configurable via Per-Route Options**: Easily configurable via per-route options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same words twice.
WDYT about
Configurable via Per-Route Options: Hash-Based load-balancing setup through application route options
hash-based-routing.html.md.erb
Outdated
| ## <a id="key-features"></a> Key Features | ||
|
|
||
| - **Configurable via Per-Route Options**: Easily set up Hash-Based Routing using application route options | ||
| - **Consistent Hashing**: Implements the Maglev consistent hashing algorithm as outlined in the paper "Maglev: A Fast and Reliable Software Network Load Balancer" (https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - **Consistent Hashing**: Implements the Maglev consistent hashing algorithm as outlined in the paper "Maglev: A Fast and Reliable Software Network Load Balancer" (https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf) | |
| - **Consistent Hashing**: Consistent hashing via the Maglev Algorithm (see [Maglev: A Fast and Reliable Software Network Load Balancer](https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf) for details) |
hash-based-routing.html.md.erb
Outdated
|
|
||
| - **Configurable via Per-Route Options**: Easily set up Hash-Based Routing using application route options | ||
| - **Consistent Hashing**: Implements the Maglev consistent hashing algorithm as outlined in the paper "Maglev: A Fast and Reliable Software Network Load Balancer" (https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf) | ||
| - **Minimal Rehashing**: Uses the Maglev lookup table to map application instances by hash, minimizing changes to hash assignments when application instances are added or removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - **Minimal Rehashing**: Uses the Maglev lookup table to map application instances by hash, minimizing changes to hash assignments when application instances are added or removed | |
| - **Minimal Rehashing**: The Maglev Algorithm minimizes changes to the mapping table (header->instance), when application instances are added or removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the (header->instance) bit, or at least change it to (hash -> instance).
hash-based-routing.html.md.erb
Outdated
| - **Minimal Rehashing**: Uses the Maglev lookup table to map application instances by hash, minimizing changes to hash assignments when application instances are added or removed | ||
| - **Configurable Hash Header**: Allows specifying which HTTP header to use for hashing via the `hash_header` property | ||
| - **Session Affinity Precedence**: Prioritizes session affinity, or sticky sessions, over hash-based routing when available | ||
| - **Handling imbalanced loads**: Implements detection and mitigation of higher request loads on single instances due to different usage patterns for specific hashes. This avoids overloading a single instance while keeping instances for a particular hash at a minimum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - **Handling imbalanced loads**: Implements detection and mitigation of higher request loads on single instances due to different usage patterns for specific hashes. This avoids overloading a single instance while keeping instances for a particular hash at a minimum. | |
| - **Handling imbalanced loads**: Imbalanced load on a subset of instances is avoided. This avoids overloading a single instance while keeping instances for a particular hash at a minimum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"is avoided" is passive voice and that should be avoided ;-)
Co-authored-by: Clemens Hoffmann <clemens.hoffmann@sap.com>
|
@ameowlia , is this something we also need to add to the TPCF commercial docs? |
|
Note to myself -- CF OSS docs only. |
No description provided.