Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

Timeouts, 503s and 429s from a provider

One night's provisioning 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 API 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_up

photos-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.

Read each answer for what it says

Each line is a different kind of answer, and each needs its own response. Start with the 503:

HTTP/1.1 503 Service Unavailable
Retry-After: 30
Content-Type: application/json
X-Request-ID: 1e7d40b2-9c35-4f18-a6e0-58b2d9c3f471

{"error": "service_unavailable", "message": "Member writes are paused for maintenance."}

RFC 9110 defines 503 as the server being unable to handle the request right now because of temporary overload or maintenance, likely to clear after a delay. Retry-After says how long to wait, either as a number of seconds, as here, or as an HTTP date. What a 503 does not say, on its own, is that nothing happened. A gateway can return 503 after the request has already reached the service behind it, and a service can fail partway through. Whether Yuki's member was created is known only from the provider's documented contract or from looking. The printing company documents that a 503 carrying its own X-Request-ID means the write was not processed, and a lookup for photos-user-8843 finds no member. Yuki's create is safe to send again.

Kwame's first attempt is different. The job sent the request and then stopped waiting after ten seconds. That is a client-side timeout after the request was sent, and its outcome is unknown, not failed. The upstream may never have received it, may have rejected it, or may have done the work and lost the response on its way back. The job logged result=failed and tried again, and the lookup shows what really happened:

GET /v1/members?external_id=photos-user-8842 HTTP/1.1
Host: api.printer.example
Authorization: Bearer <redacted>

HTTP/1.1 200 OK
Content-Type: application/json

{"members": [
  {"id": "mbr_2208", "external_id": "photos-user-8842", "display_name": "Kwame", "created": "2026-10-19T02:00:24.611Z"},
  {"id": "mbr_2209", "external_id": "photos-user-8842", "display_name": "Kwame", "created": "2026-10-19T02:00:26.597Z"}
]}

The first request finished at the upstream about 200 milliseconds after the job gave up on it. The retry then created a second member. Looking a record up like this, to find out what actually happened before acting again, is called reconciling. Compare a connection timeout, where the job never managed to open a connection: the request was never sent, so nothing can have happened, and an immediate retry is safe.

Some answers need no retry at all. A 400 means the request is wrong and will be wrong again. A 401 invalid_client from the token endpoint means the job's credential is wrong, and a hundred more attempts will not fix it. Those call for a corrected request, and the job should stop on them at once.

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.

Three answers from the same night, each needing a different next step. The job retried all three at once, and none of them ended as one member.

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 token request with a wrong client secret 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.

Your job sends a create-account request to a provider, waits 10 seconds with no response and stops waiting. What should it do before sending the create again? 1 of 3

Choose one answer.

A provider answers your sync job with 429, Retry-After: 120, and a body naming the limit "writes-per-client" for your client. What is the right next step? 2 of 3

Choose one answer.

The provider documents an Idempotency-Key header for member creates. When should the job generate the key for Kwame's member? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity