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

feat(balancer) implement consistent hashing #2875

Merged
merged 10 commits into from
Oct 30, 2017
Merged

feat(balancer) implement consistent hashing #2875

merged 10 commits into from
Oct 30, 2017

Conversation

Tieske
Copy link
Member

@Tieske Tieske commented Sep 9, 2017

One can define 2 keys to hash on, if the first key returns nil, the fallback is used (for example if a header is not present). The options for the keys are:

  1. none: do not use a hash, just do (weighted) round-robin. This is the default.
  2. consumer: use the consumer_id, or if not found the credential_id. (later is for external auth like oauth2 or ldap)
  3. ip: use the originating ip address
  4. header: use the header specified in the additional header option. If there are multiple headers by this name, then all entries are used (concatenated)

The hash value is created from the resulting string-value, and is calculated as a numerical crc32.

@hishamhm
Copy link
Contributor

hishamhm commented Sep 9, 2017

The check function could verify that hash_header{1,2} are only non-empty when their corresponding enum is set to "hash".

As for the schema interface, instead of hash_header1 and hash_header2 I'd use names matching the enum fields they are arguments of: hash_on_header and hash_fallback_header (or else it might seem that both headers are matched), but that's a matter of taste.

@Tieske Tieske changed the base branch from master to next October 27, 2017 13:14
Minor changes to adhere to the coding rules.
Copy link
Contributor

@hishamhm hishamhm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, with minor style changes applied!

@hishamhm hishamhm merged commit 92dbf33 into next Oct 30, 2017
@thibaultcha thibaultcha deleted the feat/hashing2 branch October 30, 2017 16:28
Tieske added a commit to Kong/docs.konghq.com that referenced this pull request Oct 31, 2017
Tieske added a commit to Kong/docs.konghq.com that referenced this pull request Oct 31, 2017
Tieske added a commit to Kong/docs.konghq.com that referenced this pull request Jan 2, 2018
thibaultcha pushed a commit to Kong/docs.konghq.com that referenced this pull request Jan 12, 2018
thibaultcha pushed a commit to Kong/docs.konghq.com that referenced this pull request Jan 16, 2018
thibaultcha pushed a commit to Kong/docs.konghq.com that referenced this pull request Jan 16, 2018
thibaultcha pushed a commit that referenced this pull request Jan 16, 2018
One can define 2 keys to hash on, if the first key returns nil, the fallback is used (for example if a header is not present). The options for the keys are:

1. `none`: do not use a hash, just do (weighted) round-robin. This is the default.
2. `consumer`: use the consumer_id, or if not found the credential_id. (later is for external auth like oauth2 or ldap)
3. `ip`: use the originating ip address
4. `header`: use the header specified in the additional header option. If there are multiple headers by this name, then all entries are used (concatenated)

The hash value is created from the resulting string-value, and is calculated as a numerical crc32.

PR #2875
thibaultcha pushed a commit that referenced this pull request Jan 19, 2018
One can define 2 keys to hash on, if the first key returns nil, the fallback is used (for example if a header is not present). The options for the keys are:

1. `none`: do not use a hash, just do (weighted) round-robin. This is the default.
2. `consumer`: use the consumer_id, or if not found the credential_id. (later is for external auth like oauth2 or ldap)
3. `ip`: use the originating ip address
4. `header`: use the header specified in the additional header option. If there are multiple headers by this name, then all entries are used (concatenated)

The hash value is created from the resulting string-value, and is calculated as a numerical crc32.

PR #2875
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

Successfully merging this pull request may close these issues.

2 participants