feat(experiments): route metrics recalculation to its own temporal queue#67257
Merged
rodrigoi merged 2 commits intoJul 3, 2026
Merged
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Contributor
|
Reviews (1): Last reviewed commit: "feat(experiments): configure the metrics..." | Re-trigger Greptile |
2 tasks
305b12a to
9d166a7
Compare
Contributor
|
Reviews (2): Last reviewed commit: "fix(experiments): updating misleading co..." | Re-trigger Greptile |
…e the experiments temporal queue
9d166a7 to
a2a9cf2
Compare
jurajmajerik
approved these changes
Jul 3, 2026
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.

Problem
The experiment metrics recalculation workflow runs on the shared
general-purpose-task-queue, so its activities compete for worker slots with unrelated workflows on that queue. A burst of recalcs can starve the other workloads, and the shared worker's concurrency caps how wide a single recalc can fan out. That fan-out was pinned at 4 concurrent metrics, which makes recalculating an experiment with many metrics slow.This routes recalc to its own dedicated queue and worker so it is isolated from the general queue and can fan out wider per run.
Changes
Moves the metrics recalculation workflow off
general-purpose-task-queueonto a dedicatedexperiments-recalculation-task-queue, served by a new worker (provisioned in the companion charts PR). The timeseries recalculation workflow and the precompute canary stay on the general queue.Queue routing
Adds the
EXPERIMENTS_RECALCULATION_TASK_QUEUEsetting and registers the recalc workflow and activities on it instart_temporal_worker.py, removing them from the general-purpose entry. The workflow start in themetrics_recalculationview and the metrics interceptor'stask_queueboth point at the new queue; the interceptor must match the registration queue oris_task_queue_supportedfilters it out and Prometheus metrics stop emitting.posthog/settings/temporal.pyposthog/management/commands/start_temporal_worker.pyproducts/experiments/backend/presentation/views.pyproducts/experiments/backend/temporal/recalculation_metrics.pyproducts/experiments/backend/temporal/test_recalculation_metrics.pyWider per-run fan-out
Raises
MAX_CONCURRENT_METRICSfrom 4 to 14. The dedicated worker bounds total ClickHouse load across concurrent runs, so a single run can fan out wide enough to finish most experiments in one concurrent wave. The old cap of 4 existed because recalc shared the general queue's ClickHouse budget; that constraint no longer applies.products/experiments/backend/temporal/recalculation_workflow.pyCI image wiring
Adds a change-detection step and a
repository-dispatchtoPostHog/chartsfor thetemporal-worker-experiments-recalculationrelease, so the new worker's image state tracks builds independently. Recalc's temporal path moves off the general-purpose worker's change filter since it no longer runs there. There is no new image build; every temporal worker shares theposthog-cloudimage and only the dispatched release name differs..github/workflows/container-images-cd.ymlRollback
Revert this PR to route recalc back to
general-purpose-task-queue. The workflow itself is unchanged, only the queue it runs on and the fan-out width.Deploy order
The companion charts PR that stands up the dedicated worker must merge and the worker must be healthy before this PR merges. If this merges first, recalc workflows start but their activities sit on a queue no worker polls until the worker exists.
Recalc activities are removed from the general-purpose worker here, so a recalc run already in-flight on
general-purpose-task-queueat the cutover keeps its activities on that queue (activities inherit the workflow's task queue) and can stall once the general worker stops registering them. Recalc runs are short and user-triggered, so either let in-flight runs drain before rolling the general worker, or accept that the few runs straddling the cutover need re-triggering. New runs started after this deploys are unaffected.How did you test this code?
Automatic notifications
Docs update
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Model: Opus 4.8
Manually refactored: no
Skills used:
Relevant decisions:
MAX_CONCURRENT_METRICSto 14 so a typical experiment's metrics recalculate in a single concurrent wave. The dedicated worker's activity-slot cap, set in the charts PR, bounds total ClickHouse load across concurrent runs.general-purpose-task-queue; only the metrics recalc workflow moves, since only it needs the isolation and wider fan-out.posthog-cloudimage via its seeded charts state file, so queue routing works from the first deploy.