KatInterview

Designing a Continuously Refreshed Merchant Attribute Store

System DesignModel answer
HardModel answerSystem Designsystem-designdata-pipelinesentity-resolution

Last updated

Design a platform that links merchants to external sources, refreshes their attributes on schedule, resolves conflicts with provenance, and serves low-latency reads even when upstreams fail.

Problem

A marketplace shows a profile for each of its merchants. The profile includes a headquarters address, social follower counts, and a few encyclopedic facts such as founding year and parent company. None of this data is owned by the marketplace. It has to be gathered from outside providers: social network APIs, official business registries, a maps/geocoding service, and a public knowledge graph like Wikidata.

Design the backend that keeps this data accurate and current, and makes it quickly available to other internal services.

Capabilities required

  • Linking. Connect each internal merchant ID to the matching identifiers at each provider (a social handle, a knowledge-graph entity ID, a registry record), starting from signals like the merchant's domain or brand name.
  • Collection. Pull fast-changing metrics (follower counts) on a regular schedule. Pull slow-changing facts (address, founding year, parent company) less often. Also handle on-demand re-sync requests from merchants.
  • Traceability. Every attribute value shown must carry where it came from, how confident the system is in it, and when it was observed.
  • Graceful degradation. If one provider is throttled or offline, profiles must still be served using the most recent good values from that provider.
  • Serving. Internal consumers (profile pages, ranking) need fast reads of the current state, plus access to historical snapshots.

Scale and targets

  • 50 million merchants in total.
  • About 5 million "active" merchants need follower counts refreshed daily. The other 45 million refresh weekly.
  • Follower metrics should be no more than 24 hours old. Address and fact changes should be reflected within 7 days.
  • Reads: 20,000 per second with P99 latency under 25 ms.
  • The full change history must be retained for compliance and debugging.

What to cover in your answer

  1. The data model: dynamic attributes, provenance, confidence, and time-series history.
  2. The architecture: scheduling, rate-limited fetching, parsing, entity matching, and reconciliation.
  3. How you resolve disagreements between sources, for example two registries listing different addresses.
  4. Failure handling: provider throttling, breaking changes in provider payloads, and malformed records that repeatedly crash workers.

State your assumptions and do rough capacity math as you go.

Hints

Hint 1

Compute the average request rates first. Roughly 11M social refreshes per day is only on the order of 100 per second, so the real bottleneck is provider quotas and data quality, not raw throughput.

Hint 2

Separate the write side from the read side. Keep an append-only observation log as the source of truth, and derive a precomputed per-merchant record that reads hit with a single key lookup.

Hint 3

Do not use one global merge rule. Choose a policy per attribute type (latest-wins for metrics, authority-weighted scoring for addresses, multi-source agreement for facts), and mark unresolved authoritative conflicts as disputed rather than silently choosing.

Hint 4

For failures, think in layers: per-provider token buckets and circuit breakers, versioned parsers with a quarantine queue for payloads that fail validation, and a dead-letter path with a retry cap for poison messages.