Skip to content

Commit

Permalink
fix: Throttle pruning so hub is not overloaded (#2005)
Browse files Browse the repository at this point in the history
## Motivation

We're too aggressive during pruning which is causing hubs to become
unresponsive sometimes. Long term fix is to prune during merge, but that
involves migrating the storage cache to rust. Short term fix in the
meantime.

## Change Summary

Describe the changes being made in 1-2 concise sentences.

## Merge Checklist

_Choose all relevant options below by adding an `x` now or at any time
before submitting for review_

- [x] PR title adheres to the [conventional
commits](https://www.conventionalcommits.org/en/v1.0.0/) standard
- [x] PR has a
[changeset](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#35-adding-changesets)
- [x] PR has been tagged with a change label(s) (i.e. documentation,
feature, bugfix, or chore)
- [ ] PR includes
[documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs)
if necessary.
- [x] All [commits have been
signed](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#22-signing-commits)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers


<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on fixing the throttle pruning in `@farcaster/hubble` to
prevent hub overload.

### Detailed summary
- Updated `TIME_SCHEDULED_PER_FID_MS` to 5ms for temporary load
reduction on DB during pruning


> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
sanjayprabhu committed May 16, 2024
1 parent 920f6c0 commit 8c759d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tiny-trains-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farcaster/hubble": patch
---

fix: Throttle pruning so hub is not overloaded
2 changes: 1 addition & 1 deletion apps/hubble/src/storage/jobs/pruneMessagesJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const DEFAULT_PRUNE_MESSAGES_JOB_CRON = "0 */2 * * *"; // Every two hours

// How much time to allocate to pruning each fid.
// 1000 fids per second = 1 fid per ms. 500k fids will take under 10 minutes
const TIME_SCHEDULED_PER_FID_MS = 1;
const TIME_SCHEDULED_PER_FID_MS = 5; // Temporarily increase to 5ms per fid to reduce load on DB, while we move to pruning at merge

const log = logger.child({
component: "PruneMessagesJob",
Expand Down

0 comments on commit 8c759d6

Please sign in to comment.