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

introduces configurable dispatch hashring replication factor #1227

Merged
merged 2 commits into from
Mar 29, 2023

Conversation

vroldanbet
Copy link
Contributor

this new CLI allows parameterizing the replication factor
used in hashring used by the dispatch client-side gRPC balancer.

This was a bit more involved as the balancer registry is a global
singleton meant to be registered on an init block. This would have
required moving flag handling outside of cobra, which is not ideal.

As a solution I changed how the balancer is named, appending the replication
factor to the name, and introducing a lazy-load mechanism with a mutex:

  • if a balancer with a specific replication factor does not exist, lock is
    acquired and the balancer is registered. This avoids races if multiple
    spicedb servers are running in the same process
  • if a balancer exists already, it's not registered
  • we do not unregister the balancer when the server is wind down, as
    it could affect another spicedb instance in the process using
    the same replication factor

@vroldanbet vroldanbet requested a review from a team as a code owner March 24, 2023 20:48
@github-actions github-actions bot added area/CLI Affects the command line area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Mar 24, 2023
@vroldanbet vroldanbet self-assigned this Mar 24, 2023
@ecordell ecordell self-requested a review March 28, 2023 15:17
@@ -108,6 +111,10 @@ type Config struct {
TelemetryInterval time.Duration
}

const defaultBackendsPerKey = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be nice to make this configurable too while we're here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

does that have practical use in SpiceDB? it would cause multiple SpiceDB nodes to have the same key range, which will reduce the likelihood for cache hits, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's not very useful with smaller clusters, but with larger clusters it lets you spread the load for a hot key between multiple nodes

@vroldanbet vroldanbet force-pushed the configurable-replication-factor branch from dd0f1d8 to 47f0722 Compare March 29, 2023 11:14
so that we get most of the functionality
of the server turned on
@vroldanbet vroldanbet force-pushed the configurable-replication-factor branch from 47f0722 to 5481d3d Compare March 29, 2023 15:43
@ecordell ecordell enabled auto-merge March 29, 2023 17:48
ecordell
ecordell previously approved these changes Mar 29, 2023
Copy link
Contributor

@ecordell ecordell left a comment

Choose a reason for hiding this comment

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

LGTM

@vroldanbet vroldanbet removed the request for review from josephschorr March 29, 2023 17:58
this new CLI allows parameterizing the replication factor
used in hashring used by the dispatch client-side gRPC balancer.

This was a bit more involved as the balancer registry is a global
singleton meant to be registered on an init block. This would have
required moving flag handling outside of cobra, which is not ideal.

As a solution I changed how the balancer is named, appending the replication
factor to the name, and introducing a lazy-load mechanism with a mutex:
- if a balancer with a specific replication factor does not exist, lock is
  acquired and the balancer is registered. This avoids races if multiple
  spicedb servers are running in the same process
- if a balancer exists already, it's not registered
- we do not unregister the balancer when the server is wind down, as
  it could affect another spicedb instance in the process using the
  same replication factor
@ecordell ecordell merged commit 237072e into main Mar 29, 2023
@ecordell ecordell deleted the configurable-replication-factor branch March 29, 2023 19:10
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/CLI Affects the command line area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants