Timeouts, 503s and 429s from a provider
One night's provisioningCreating accounts in applications, keeping their attributes and access current, and disabling them when people leave, without waiting for each person to sign in. SCIM is a standard way to send those changes. job created Kwame twice and Yuki and Wren not at all. This lesson reads a timeout, a 503 and a 429 for what each one says, reconciles an unknown outcome before any retry, makes a retry safe with an idempotency key, backoff and Retry-After, and finds out whose rate limit the job hit.
One person twice, two people not at all
Esme runs a small studio with a business account at the photo service. When she adds someone to her team, an overnight job at the photo service creates a matching member at the printing company, so the new person can order prints on the studio's account. On Monday she writes in: "Kwame shows up twice in our printing account. Yuki and Wren were added yesterday and they don't show up at all."
The job calls the printing company's member APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests. at api.printer.example, authenticating as the client photos-provisioning. That API is the job's upstream: a service it depends on and does not control. The job's own log for the night shows three kinds of trouble in under fifteen seconds:
02:00:14.118Z member.create external_id=photos-user-8841 attempt=1 201 Created member=mbr_2207 184 ms
02:00:14.402Z member.create external_id=photos-user-8842 attempt=1 timeout: no response after 10000 ms (request sent) result=failed
02:00:24.405Z member.create external_id=photos-user-8842 attempt=2 201 Created member=mbr_2209 2210 ms
02:00:26.731Z member.create external_id=photos-user-8843 attempt=1 503 retry_after=30
02:00:26.744Z member.create external_id=photos-user-8843 attempt=2 503 retry_after=30
02:00:26.758Z member.create external_id=photos-user-8843 attempt=3 429 retry_after=60
02:00:26.771Z member.create external_id=photos-user-8843 attempt=4 429 retry_after=59
02:00:26.785Z member.create external_id=photos-user-8843 attempt=5 429 result=gave_upphotos-user-8842 is Kwame and photos-user-8843 is Yuki. Wren, photos-user-8844, appears further down with nothing but 429s. Look at the gaps between Yuki's attempts: thirteen milliseconds. The upstream asked for thirty seconds and the job waited for none of them. The job handles new members for every business customer, forty that night, with eight workers each doing the same thing, so a short maintenance pause at the printing company turned into a burst of retries, and the burst turned into a rate limit. Retrying did not make the upstream recover any faster. It made the incident bigger.
Make a retry safe before you make it
Retrying a read is harmless. Retrying a write that may already have happened is how Kwame ended up twice. There are two common ways to make a retried write safe, and the printing company's API supports both.
The first is an idempotency key: a unique value the client generates once for one operation it means to perform and sends with every attempt at it. The provider stores the first result under that key and returns the same result to any later request carrying it, instead of doing the work again:
POST /v1/members HTTP/1.1
Host: api.printer.example
Authorization: Bearer <redacted>
Idempotency-Key: 6c0b8f4e-2a91-4d77-b3f5-0e9a1c7d2b64
Content-Type: application/json
{"external_id": "photos-user-8842", "display_name": "Kwame", "account": "studio-4410"}The key belongs to the operation, not the attempt. Generate it when the job decides to create Kwame's member, store it with that pending operation, and send the same key on every retry. A new key per attempt protects nothing. An Idempotency-Key header is a widely used convention rather than an HTTP standard, so rely on it only where the provider documents it, including how long it remembers keys.
The second is a stable external identifier. The job already sends external_id, the photo service's own ID for the person. If the provider enforces it as unique, a duplicate create is refused with a conflict instead of producing a second member, and the job can reconcile by looking it up. The printing company accepted external_id but did not enforce uniqueness, which is why the lookup returned two records. Where neither exists, reconcile before every retry of a write whose outcome is unknown.
Retry slowly, and stop
For answers that are worth retrying, the shape of the retry matters as much as the decision. Exponential backoff doubles the wait after each failure: about 1 second, then 2, then 4, up to a cap. Jitter picks a random wait up to that limit, so eight workers that failed at the same moment do not all retry at the same moment again. When the response carries Retry-After, treat it as the minimum wait: Yuki's create should not have gone out again for thirty seconds.
Then stop. Cap both the number of attempts and the total time, and share one retry budget across the workers so that one bad minute at the upstream cannot multiply into hundreds of requests. An operation that runs out of attempts is not dropped. The job parks it as needing attention, so Yuki and Wren show up in a report the next morning instead of silently never existing. Record every unknown outcome as unknown, with the upstream's request ID if one came back, so that whoever reconciles it later knows exactly what to look up.
Find out whose limit you hit
The 429s need their own reading. RFC 6585 defines 429 Too Many Requests as the client having sent too many requests in a given amount of time. A useful 429 tells you which limit, and the printing company's does:
HTTP/1.1 429 Too Many Requests
Retry-After: 60
Content-Type: application/json
X-Request-ID: 8a2f6c19-04d3-4e8b-b71a-c95e03d6f2a8
{
"error": "rate_limited",
"limit": "member-writes-per-client",
"limit_value": 120,
"window_seconds": 60,
"client_id": "photos-provisioning",
"reset": "2026-10-19T02:01:26Z"
}Every limit is accountable to something: a client, a user, an account, an address. This one counts member writes per client, and it is attributed to photos-provisioning, the job itself. The printing company's usage figures for that client show 120 of 120 used, resetting at 02:01:26, and the job's log accounts for all of them: forty members, eight workers, up to five attempts each, with no waits. Nobody cut the job's capacity and no other customer used it up. The rate limit was the job's own retry storm, triggered by the maintenance pause.
Someone on the team suggests registering a second client to get a second allowance. Do not switch credentials to dodge a limit. It usually breaks the provider's terms, it hides the usage that the limit exists to make visible, and the backoff fix removes the reason for it.
Kwame, photos-user-8842
- First answer
- Timeout after send
- Did it happen
- Unknown
- Next step
- Reconcile, then retry with the same Idempotency-Key
- What the job did
- Retried at once
Two members
Yuki, photos-user-8843
- First answer
- 503, Retry-After 30
- Did it happen
- No, documented
- Next step
- Wait 30 s, then retry
- What the job did
- Retried 13 ms later
No member
Wren, photos-user-8844
- First answer
- 429, member-writes-per-client
- Did it happen
- No
- Next step
- Wait, then find whose limit
- What the job did
- Retried until it gave up
No member
Retrying did not make the upstream recover any faster. It made the incident bigger.
Verify one effect per operation
The printing company removes the duplicate mbr_2209 through its supported member merge, since it had no orders. The job is changed to send idempotency keys, reconcile unknown outcomes before any retry, back off with jitter, honour Retry-After and stop on errors that will not change. Then it runs again.
Verification is about final state, not a green dashboard. Each of the four people Esme added has exactly one member: the lookup by external_id returns one record for Kwame, one for Yuki, one for Wren and one for photos-user-8841. Running the job a second time creates nothing. And one request must still be refused: a tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret. request with a wrong client secretA shared secret that a confidential client uses to prove itself to the authorization server, much like a password for an application. It belongs on a backend, never in code sent to browsers or phones. gets 401 invalid_client, and the job stops at once without entering its retry loop. The job's attempt record keeps the history honest too. Kwame's first attempt reads "unknown, reconciled: applied as mbr_2208", not "failed", because that is what it was.
Worked example: the reconciled attempt record
After the repair, the job's record of the night reads like this. Each original operation keeps its first outcome, what reconciliation found and what finally happened, so nobody has to guess whether an earlier attempt did anything:
Operation First outcome Reconciled Final state
create photos-user-8841 201, mbr_2207 not needed 1 member (mbr_2207)
create photos-user-8842 timeout after send: unknown applied, mbr_2208 at 02:00:24.6 1 member (mbr_2208); duplicate
mbr_2209 merged by provider
create photos-user-8843 503 (request 1e7d40b2-...) not applied (lookup empty) 1 member (mbr_2231), created
on rerun after Retry-After
create photos-user-8844 429 member-writes-per-client not applied (lookup empty) 1 member (mbr_2232), created
on rerun
Retry policy now: 503 or 429: wait at least Retry-After, else backoff 1 s, 2 s, 4 s ... cap 60 s, full jitter,
at most 5 attempts in 10 minutes, shared budget across workers, then park for review.
Timeout after send: reconcile first; retry only with the operation's own Idempotency-Key.
400, 401, 403: stop, no retry.
Still refused: Token request with a wrong client secret: 401 invalid_client, no retries attempted.Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Restore the integration without multiplying its workTell confirmed temporary unavailability from an unconfirmed result, reconcile each original operation before any retry, write a bounded retry policy and check the usage your attempts consumed.