Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

perf(warehouse-sources): pace Metronome usage at 7.5 requests a second (#103715)

Daniel RCf038a6f398e6
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/metronome/metronome.py b/products/warehouse_sources/backend/temporal/data_imports/sources/metronome/metronome.py
index d13bc73e75b8..692cf3e20d49 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/metronome/metronome.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/metronome/metronome.py
@@ -70,14 +70,16 @@ USAGE_COALESCE_ROWS = 20_000
# first sync costs one request per page whatever the account holds, and a large account runs to
# hundreds of thousands of requests. Customers are independent, so walk several at once. The
# endpoint sits in Metronome's default rate tier, 8 requests a second shared with every other table
-# on the same account, so take well under it and leave the rest for the account's other syncs.
-# Two, not more: the pacer below is what governs throughput, and at the latency this endpoint
-# answers in, two workers already saturate it. Each worker holds one customer's rows while it walks
-# them, so a third would buy no request rate and cost another customer's worth of memory. More
-# workers only pay off if the endpoint slows enough for the workers, rather than the rate, to become
-# the limit.
+# on the same account. Hold just under the tier rather than far below it: the request count is what
+# sets how long a first sync takes, so rate left unused is time the walk cannot get back, and a
+# throttle costs one hold instead of the run.
+# Two workers, not more: the pacer is what governs throughput, and two are enough to keep the rate
+# above saturated at the latency this endpoint answers in. Each worker holds one customer's rows
+# while it walks them, so a third would buy no request rate and cost another customer's worth of
+# memory. More workers only pay off if the endpoint slows enough for the workers, rather than the
+# rate, to become the limit.
USAGE_CUSTOMER_CONCURRENCY = 2
-USAGE_REQUESTS_PER_SECOND = 5.0
+USAGE_REQUESTS_PER_SECOND = 7.5
# Metronome documents its limit per second and documents no Retry-After, so a throttled pool only
# has to stand down for a second or two, and it has to decide that for itself. The pacer's own
# default is sized for a vendor that sends the header and falls back rarely.