Design a Mobile Application Event Collection API
Design a reliable, privacy-aware API that accepts mobile application events despite retries, offline clients, and evolving schemas.
Problem statement
For this exercise, assume mobile applications use an SDK to collect product events and submit bounded batches to a shared ingestion API. Clients may be offline for days, repeat requests after uncertain responses, and send events created under older schema versions.
The service must give producers an explicit accepted, rejected, or partially accepted result, preserve one logical effect per event, and make accepted data available to downstream consumers with visible freshness and quality state.
App teams publish versioned event schemas and collection policies; malformed, unauthorized, or policy-ineligible records must not silently enter curated data. Design the API, durable ingestion path, state model, and operational controls.
Keep analytics queries, advertising activation, and arbitrary device-log collection out of scope.
What to build
- Authorized app teams can publish immutable event-schema and collection-policy versions and inspect which version is active.
- A mobile client can submit a bounded batch with stable event identities and receive per-batch and per-event accepted, rejected, duplicate, or retryable outcomes.
- Accepted events become available to authorized downstream consumers with schema version, event time, ingestion time, provenance, and a visible freshness watermark.
- Operators can inspect lag, throttling, schema failures, quarantines, and replay progress and can recover accepted work without producing an extra logical event.
At scale
- For this exercise, assume 50 million daily active devices produce two billion events per day, with bursts of 200,000 events per second and an average encoded event size of one kilobyte.
- For this exercise, allow 1 to 500 events and at most one MiB per request, and target 300 milliseconds p95 to durably decide a healthy batch.
- For this exercise, make 99 percent of accepted events available to curated consumers within five minutes, while accepting valid offline events up to seven days late.
- For this exercise, retain immutable accepted envelopes for 30 days and curated events for 13 months; acknowledged batches must survive a single-zone failure.