Why this work, at that time
Yelp introduced Request-A-Quote in 2016 and submissions grew quickly through the year, which made lead routing and merchant response workflows the problem worth solving.
The problem
One consumer lead could route to several merchants. Messages could time out or retry, but a merchant inbox must never show the same lead twice and the consumer must always see a durable status.
The team and my part
Six engineers: three backend, one merchant web, one consumer and mobile, one platform partner, with PM, QA and merchant operations shared. I designed the quote request transaction and the notification worker.
Data and index design
quote_request(id, consumer_id, category, state, created_at); quote_recipient(request_id, merchant_id, delivery_state); outbox(id, aggregate_id, type, created_at); delivery_attempt(id, recipient, attempt, outcome). Unique on (request_id, merchant_id).
API and event contract
POST /v1/quote-requests with an Idempotency-Key header; GET /v1/quote-requests/{id}. Internal event quote.created {id, category, recipient_ids}. States: CREATED, ROUTED, PARTIALLY_DELIVERED, RESPONDED.
Core logic
Create the request and its recipients in one database transaction and write the outbox record in the same commit, then process asynchronously. The delivery worker dedupes on request, merchant and event type, retries with capped exponential backoff and dead-letters poison events.
Implementation sequence
- Define eligibility rules and immutable request ids; write the provider-failure matrix with the PM.
- Create normalized MySQL tables and unique constraints; add a request-level idempotency store.
- Commit the request and outbox atomically; add a polling or change-capture publication worker.
- Implement the merchant notification adapter and independent delivery status updates.
- Run duplicate-post, crash-after-commit, replay and provider-throttle tests; launch by service category.
Environments and release
Python service and queue workers; an integration environment with stubbed email and push providers; production rollout by service category with a dashboard for delivery lag and dead letters.
Failure drill
A worker crashes after sending but before acknowledging, so the message is resent. Email is at-least-once, but the recipient record is idempotent, so the inbox shows one lead.
Scale and targets
Modeled scale
- 2K requests per day, about three merchants each
- About 6K delivery attempts per day with bursts
- 25K eligible merchants in the rollout
Acceptance targets
- User-visible delivery status p95 within 15 seconds
- No duplicate inbox lead records
- Dead-letter replay within 30 minutes
The trade-off I would defend
Never call three message providers synchronously inside the customer's HTTP request. A durable outbox trades instantaneous notification for correctness.
