Skip to content

feat(admin): LFU replica selector#396

Merged
ijsong merged 1 commit intomainfrom
lfu_replica_selector
Apr 6, 2023
Merged

feat(admin): LFU replica selector#396
ijsong merged 1 commit intomainfrom
lfu_replica_selector

Conversation

@ijsong
Copy link
Copy Markdown
Member

@ijsong ijsong commented Apr 5, 2023

What this PR does

This PR adds a new replica selector based on the Least Frequently Used (LFU) algorithm.
lfuReplicaSelector selects each replica's storage node and data path, giving preference to those
with fewer assigned replicas.

All replica selectors, including lfuReplicaSelector, are stateless, meaning they don't keep
existing log stream topology. When Select is invoked, lfuReplicaSelector collects used counters
for each storage node and path. Although it seems to be inefficient, it is simple as well as
fault-tolerant.

To select the least used storage nodes and paths, lfuReplicaSelector runs as follows:

  • Fetch cluster metadata from the ClusterMetadataView.
  • Increase the used counters for each storage node and path assigned to each log stream.
  • Sort counters.
  • Choose the least used storage nodes and paths.

Which issue(s) this PR resolves

Updates #393

@ijsong
Copy link
Copy Markdown
Member Author

ijsong commented Apr 5, 2023

@ijsong ijsong self-assigned this Apr 5, 2023
@github-advanced-security
Copy link
Copy Markdown

You have successfully added a new CodeQL configuration .github/workflows/codeql.yml:analyze/language:python. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab.

@ijsong ijsong linked an issue Apr 5, 2023 that may be closed by this pull request
6 tasks
@github-advanced-security
Copy link
Copy Markdown

You have successfully added a new CodeQL configuration .github/workflows/codeql.yml:analyze/language:go. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 5, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.07 🎉

Comparison is base (ad1226e) 63.61% compared to head (0e08901) 63.68%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@                     Coverage Diff                     @@
##           random_replica_selector     #396      +/-   ##
===========================================================
+ Coverage                    63.61%   63.68%   +0.07%     
===========================================================
  Files                          131      131              
  Lines                        17772    17793      +21     
===========================================================
+ Hits                         11306    11332      +26     
+ Misses                        5925     5922       -3     
+ Partials                       541      539       -2     
Impacted Files Coverage Δ
internal/admin/config.go 85.85% <100.00%> (ø)
internal/admin/replica_selector.go 95.74% <100.00%> (+5.74%) ⬆️

... and 8 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Copy Markdown
Member

@hungryjang hungryjang left a comment

Choose a reason for hiding this comment

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

It seems that there will be an issue with the primary being crowded. The selection algorithm is likely to change several times.

@ijsong
Copy link
Copy Markdown
Member Author

ijsong commented Apr 5, 2023

It seems that there will be an issue with the primary being crowded. The selection algorithm is likely to change several times.

@hungryjang, you are right. Simply picking a storage node cannot balance the number of primary replicas among the nodes, and LFU selection selects the best node possible. We can add new strategies with new names.

This PR adds a new replica selector based on the Least Frequently Used (LFU) algorithm.
`lfuReplicaSelector` selects each replica's storage node and data path, giving preference to those
with fewer assigned replicas.

All replica selectors, including `lfuReplicaSelector`, are stateless, meaning they don't keep
existing log stream topology. When `Select` is invoked, `lfuReplicaSelector` collects used counters
for each storage node and path. Although it seems to be inefficient, it is simple as well as
fault-tolerant.

To select the least used storage nodes and paths, `lfuReplicaSelector` runs as follows:

- Fetch cluster metadata from the `ClusterMetadataView`.
- Increase the used counters for each storage node and path assigned to each log stream.
- Sort counters.
- Choose the least used storage nodes and paths.

Updates #393
@ijsong ijsong force-pushed the random_replica_selector branch from 93b86ff to ad1226e Compare April 6, 2023 02:43
@ijsong ijsong force-pushed the lfu_replica_selector branch from 690b414 to 0e08901 Compare April 6, 2023 02:43
@ijsong
Copy link
Copy Markdown
Member Author

ijsong commented Apr 6, 2023

@ijsong queued this pull request to merge with Graphite.

Base automatically changed from random_replica_selector to main April 6, 2023 03:29
@ijsong ijsong merged commit dfbaef0 into main Apr 6, 2023
@ijsong ijsong deleted the lfu_replica_selector branch April 6, 2023 03:29
@ijsong
Copy link
Copy Markdown
Member Author

ijsong commented Apr 6, 2023

@ijsong merged this pull request with Graphite.

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.

admin: methods to select replicas for log stream

4 participants