Preparing your design workspace

Loading the problem and your latest saved attempt…

Design an Exact User-ID Membership Store

Support exact membership and atomic add-if-absent over one million IDs under contrasting memory budgets.

Problem statement

For this exercise, assume a service holds one million opaque user IDs and supports exact membership lookup and adding an ID only when absent. IDs are fixed 128-bit values; transport encodes them as 32 hexadecimal characters with no business fields. The set grows by additions only.

A caller can check membership or atomically add an ID; concurrent additions of the same ID produce one inserted result and other already-present results. A success is acknowledged only after the ID survives a process restart.

After a timed-out add, checking or retrying that same ID must safely converge on membership without removing or duplicating it. Compare a memory-rich profile with 128 MB available for its index and a constrained profile with 16 MB.

Both profiles return exact answers: an approximate filter may accelerate lookup but cannot be the final authority. Discuss latency, memory, accuracy, and the relationship between an in-memory set, Bloom filters, a mutable memory table, and immutable disk tables.

Exclude usernames, account ownership, normalization, deletion, TTL, scans and access-control design.

What to build

  1. A caller can check whether one valid opaque user ID is in the set and receives present, absent or unavailable rather than a false answer.
  2. A caller can atomically add one valid user ID and receives inserted or already present, with restart-safe persistence before acknowledged success.
  3. A caller can check or retry the same ID after a lost add response without creating duplicate set entries.

At scale

  • For this exercise, the baseline holds one million 128-bit IDs and peaks at 20,000 lookups and 2,000 additions per second.
  • For this exercise, compare 128 MB and 16 MB index-memory budgets; account for data-structure overhead and disk read/write amplification.
  • For this exercise, target healthy membership lookup within 10 ms p95 in the memory-rich profile and 50 ms p95 in the constrained profile, with durable additions within 100 ms p95.
  • For this exercise, exactness and restart-safe acknowledged additions take priority over availability when the authority cannot be read or durably changed.