gRPC, real-time APIs and webhooks · senior
Webhooks: delivery, retries and signatures
A webhook is at-least-once delivery over HTTP. Senders use an outbox, per-endpoint queues, backoff and a signature. Receivers answer fast, verify the signature on the raw body and de-duplicate by event id.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Exactly once is impossible over HTTP: when a request times out, the sender cannot know if it was processed. Deliver at least once and say so in the docs.
- Receiver: check the signature first, store the event, answer 2xx fast, process in the background, and de-duplicate by event id with a unique constraint.
- Sender: the same event id and payload on every retry, exponential backoff with jitter, a documented timeout (about 10 to 15 seconds), a log of every attempt, and a dashboard and resend button for partners.
- Capture with an outbox table written in the same database transaction as the change. A relay publishes to a queue. No event without a committed change, and none lost in a crash.
- Isolate endpoints: per-endpoint queues or concurrency limits and a circuit breaker, so one slow merchant fills only its own lane. After days of failures, mark the endpoint failing, email the merchant and keep events for replay.
- Signing: HMAC-SHA256 over the id, timestamp and raw body with a per-endpoint secret. Verify with a constant-time comparison, reject timestamps older than about 5 minutes (replay), and accept several signatures during secret rotation.
- Verify on the raw bytes. Parsing and re-serialising JSON changes spacing and key order, so the HMAC will not match. Many frameworks parse first, so capture the raw body.
The red pen
Common traps: mistake → fix
Mistake: A webhook is sent exactly once
Fix: It is at least once. Receivers must handle duplicates.
Mistake: I can compare signatures with ==
Fix: Use a constant-time comparison to avoid timing attacks.
Mistake: I can verify the signature on the parsed JSON
Fix: Spacing and key order change. Use the raw bytes.
Easy to hard
Questions interviewers ask, easy to hard
- Why are webhooks at-least-once and what must a receiver do about it?
- A partner got the same webhook three times. How do you explain it from the logs?
- How do you sign and verify a webhook? Why include a timestamp?
- Why use an outbox for webhook events?
- Design webhook delivery for 5,000 merchants where some endpoints are slow or down.
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.