Design a Campaign Milestone Visitor Reward
Design a campaign-page service that identifies exactly one millionth eligible visitor and fulfills that visitor’s reward safely under high concurrency and failures.
Problem statement
For this exercise, assume a public campaign page records one eligible visit per stable visitor during the campaign.
The system must assign a unique increasing ordinal to each first eligible visit, designate the visit with ordinal 1,000,000 as the sole winner, let a visitor retrieve only their own result, and initiate one reward fulfillment for that winner.
Duplicate browser requests, client retries, process failures, delayed messages, and ambiguous downstream responses are expected. The winner assignment must never change after it is committed. Reward fulfillment may be asynchronous, but it must be auditable and must not create duplicate grants.
Exclude page-content delivery, ad targeting, bot-detection internals, identity enrollment, payment processing internals, and campaigns with more than one milestone.
What to build
- Record the first eligible visit for a stable campaign visitor and return a retry-safe result.
- Assign ordinal 1,000,000 to exactly one eligible visit and durably mark that visitor as the sole winner.
- Allow a visitor to retrieve only their own committed ordinal and winner status.
- Initiate and track one auditable reward fulfillment for the committed winner without duplicate grants.
At scale
- Assume a single six-hour campaign receives 50,000 page requests per second at peak and 100 million total requests.
- At least 99.99% of accepted first-visit results should be available within 500 milliseconds; an ambiguous response may be resolved by a status lookup.
- Winner assignment and accepted-visit state must survive a process or single-zone failure with no duplicate ordinal or winner.
- Reward fulfillment may take up to 24 hours, but workflow status and reconciliation evidence must remain available for 90 days.