Skip to content

Queue the builds CDN purge instead of sleeping in the request - #308

Merged
ericmj merged 1 commit into
mainfrom
async-builds-purge
Sep 22, 2026
Merged

ericmj merged 1 commit into
mainfrom
async-builds-purge

Conversation

@ericmj

@ericmj ericmj commented Sep 22, 2026

Copy link
Copy Markdown
Member

POST /api/artifacts/add purged Fastly inline, and Bob.Fastly.purge/3 sleeps 4 seconds between each of its three requests, so every artifact upload from otp.sh held its request open for about 8.1 seconds. Bob serves 9 to 14 other requests per 5 minutes, so one upload every 5 minutes puts more than 5% of requests in the 5000-10000ms histogram bucket. A burst of OTP builds (up to 6 per ref) keeps p95 above 2000ms long enough to fire HttpLatencyHigh. Replaying the rule against the request logs in hexpm-prod.logs.stdout from 2026-09-03 to 2026-09-22 predicts firings on 09-07, 09-09, 09-16, 09-17, 09-19 and 09-22, each during an OTP build burst. 449 of the 450 bob requests over 5 seconds in that period were this route.

Bob.Artifacts.add/1 still saves the row and writes builds.txt during the request, then queues Bob.Job.PurgeBuilds with the surrogate keys. The job is exempt from backoff: nothing re-queues a purge, so backing off after a failure would skip the next build's purge of the same keys.

The master only runs jobs listed in BOB_LOCAL_JOBS, and boot fails if a listed module doesn't exist. The hexpm-ops change adding Bob.Job.PurgeBuilds to BOB_LOCAL_JOBS has to ship in the same commit as the image bump to this change.

POST /api/artifacts/add purged Fastly inline, and Bob.Fastly.purge/3
sleeps 4 seconds between each of its three requests, so every artifact
upload from otp.sh held its request open for about 8.1 seconds. Bob
serves 9 to 14 other requests per 5 minutes, so one upload every 5
minutes puts more than 5% of requests in the 5000-10000ms histogram
bucket, and a burst of OTP builds (up to 6 per ref) keeps p95 above
2000ms long enough to fire HttpLatencyHigh. Replaying the rule against
the request logs from 2026-09-03 to 2026-09-22 predicts firings on
09-07, 09-09, 09-16, 09-17, 09-19 and 09-22, each during an OTP build
burst. 449 of the 450 bob requests over 5 seconds in that period were
this route.

add/1 still saves the row and writes builds.txt during the request,
then queues Bob.Job.PurgeBuilds with the surrogate keys. The job is
exempt from backoff: nothing re-queues a purge, so backing off after a
failure would skip the next build's purge of the same keys.

The master only runs jobs listed in BOB_LOCAL_JOBS, and boot fails if a
listed module doesn't exist, so the hexpm-ops change adding
Bob.Job.PurgeBuilds to BOB_LOCAL_JOBS has to ship in the same commit as
the image bump to this change.
@ericmj
ericmj marked this pull request as ready for review September 22, 2026 09:50
@ericmj
ericmj merged commit cb85fb1 into main Sep 22, 2026
4 checks passed
@ericmj
ericmj deleted the async-builds-purge branch September 22, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant