Repository navigation
perf(backend-sync): restore backfill-lane routing behind a default-off flag - #11966
Merged
Merged
Conversation
…f flag The always-on worker is paying for ~95% backfill traffic the idle backend-sync-backfill service was provisioned to take; keep #10400's main-queue default until the 30-wide worker is proven in production.
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.
Summary
Always-on
backend-sync(Cloud Run, minScale 5) is running at 16–22 instances and costing ~$63.5/day net becauseenqueue_sync_jobsends every sync job to the main queue. 95% of lane tokens arelane=backfill. The already-provisionedbackend-sync-backfillworker took 0 HTTP requests in 6 hours and costs $2.30/day sitting idle.Live config, verified 2026-08-20:
backend-sync:SYNC_TASKS_QUEUE=sync-jobs, minScale 5, max 25, cpu-throttling=false, concurrency 20backend-sync-backfill:SYNC_BACKFILL_TASKS_QUEUE=sync-backfill,SYNC_BACKFILL_ENABLED=true, minScale 1, max 30, request-based, concurrency 1/v2/sync-jobs/run(STT) 17,268 s/h = ~61%; audio-merge 10,660 s/h; admission 481 s/hModelled saving: always-on 18 → ~7 instances (−$38/day), request-based backfill picks up ~4.8 concurrent STT jobs (+$17/day) ⇒ net ~$15–25/day.
This PR restores lane-based queue selection in
enqueue_sync_job:lane=backfillgoes toSYNC_BACKFILL_TASKS_QUEUE+ the backfill handler URL; everything else keeps the main queue. Audio-merge routing, minScale, and deploy YAML are out of scope.Why this is not a naive revert of #10400
The two-lane split was collapsed in #10400 deliberately, to fix a real customer incident. Offline recordings can never carry server capture proof, so they all classify as
lane=backfill. That sent the entire offline workload to a lane provisioned for occasional historical recovery. The backfill worker admitted only a few jobs at once (~4-dispatch), so Cloud Tasks retried the surplus with exponential backoff until recordings sat unprocessed for many hours.A naive restore of that routing would re-open that incident. It is safe to restore now because the backfill worker's admission capacity changed: it is maxScale 30, concurrency 1, request-based — i.e. 30 concurrent jobs, versus the ~4-dispatch lane that caused the incident.
Flag
SYNC_BACKFILL_ROUTING_ENABLED(defaultfalse). With the flag off, behaviour is byte-identical to today: every job still goes to the main queue. With the flag on,lane=backfillis routed to the backfill queue/handler (including the backfill OIDC audience). If the backfill queue or handler env vars are unset or empty, the job falls back to the main queue and is never dropped.Rollout
SYNC_BACKFILL_ROUTING_ENABLEDunset/false. No traffic moves.SYNC_BACKFILL_ROUTING_ENABLED=trueon the enqueueing service once the 30-wide backfill worker is confirmed live.backend-sync-backfillstarts taking/v2/sync-jobs/runtraffic and always-oninstance_countfalls. Flip the flag off immediately if recordings stall or always-on occupancy does not move.Rollback bar
If
backend-sync+backend-sync-backfillcombined net over 7 closed UTC days is >= $56/day, the routing change saved nothing and the flag goes back off.Independently: if always-on
instance_countALIGN_MEAN over 48 matched hours stays >= 16, STT did not leave the lane.Tests
cd backend && python -m pytest tests/unit/test_sync_cloud_tasks.py→ 90 passed.🤖 Generated with Claude Code