Repository navigation
perf(api): slow pg-boss polling to cut Vercel Fluid CPU use - #62
Merged
Merged
Conversation
Workers polled Postgres every 2s each, so every warm instance burned Active CPU even with no traffic and the Hobby limit was exceeded. Job workers now poll every 30s, cron workers every 60s, and the scheduler and maintenance loops run less often.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Production hit the Hobby fair-use limit for Fluid Active CPU (hack-village was ~53% of the team's ~3h50m over 30 days) with almost no traffic.
instrumentation.tsstarts pg-boss on every serverless boot. It registers about 10 workers at the default 2s poll, so each warm instance runs roughly 5 queries per second and burns CPU while idle.What
cronMonitorIntervalSecondsandcronWorkerIntervalSecondsare 45s (the maximum) andmaintenanceIntervalSecondsis 600s.Impact
Notes
payout.*andescrow.*worker registrations (timing only), so the escrow/payout review rules apply.tsc --noEmitpasses. Integration tests not run locally (need Postgres); CI will run them.