Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Design a Globally Unique Username
& Identity Claim Service.

Design a global username and identity claim service handling 500K availability checks/sec (<10ms p99), 5K linearizable claims/sec (<150ms p99), anti-spoofing normalization, and 90-day rename cooldowns.
Start the journey7 stages· Last modified Nov 24, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When nodes partition or reboot past retry windows, serve 500K/s checks from Edge Bloom Filters + Redis negative caches, and serialize 5K/s claims via CockroachDB/Spanner Raft range leases with an Idempotent Outbox and Cooldown Graveyard.

TL;DR30-second simplified summary
▾

A 1.2GB Edge Bloom filter (1% FP for 1B keys) + regional Redis absorbs 99% of 500K RPS availability checks. Writes pass NFKC/UTS #39 canonicalization and an O(N) Aho-Corasick profanity trie before committing on hash-sharded CockroachDB/Spanner Raft leaseholders.

A Transactional Outbox streams committed claims with monotonic fencing tokens to Profile services and Edge caches in <500ms.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Globally Unique Identity Claim Consensus
Globally Unique Identity Claim Consensus guarantees that two users in different continents can never claim the same canonical username simultaneously, combining Unicode NFKC/homoglyph normalization with linearizable Raft/Paxos quorum writes.
Full walkthrough · 7 stages
01
foundation

Workload Asymmetry & Sizing (500K Reads vs 5K Writes).

Why this matters: Quantify keystroke check QPS, claim QPS, and Bloom Filter memory footprint.

Think of Workload Asymmetry & Sizing (500K Reads vs 5K Writes) as the intuition layer for Design a Globally Unique Username & Identity Claim Service: Quantify keystroke check QPS, claim QPS, and Bloom Filter memory footprint.

At 500K checks/sec and 5K claims/sec (100:1 asymmetry) over 1B total accounts: each identity row (~250 bytes) totals ~250GB raw (~750GB replicated). A 1% false-positive Bloom Filter for 1B handles requires 1B * 9.6 bits = ~1.2GB—fitting effortlessly in RAM on every Edge POP.

Stage 1 - Capacity Model

500K Read / 5K Write Sizing

500K RPS Checkssource1.2 GB Bloom Filtercache5K RPS Claimsprocessor250 GB Raw Storestorage5K Raft txns/sec

1.Hash Sharding: Shard Raft ranges by hash(canonical_handle) so 'a*' or 'the*' prefixes don't hot-spot.

2.Memory Efficiency: 1.2GB Bloom filter fits inside standard Edge POP containers.

100:1 read/write asymmetry is cleanly absorbed by a 1.2GB Edge Bloom filter and hash-sharded Raft.

02
foundation

Read Path: Edge Bloom Filter -> Redis -> Read Replica.

Why this matters: Deliver <10ms p99 availability checks globally without hitting the consensus leader.

Availability checks hit the nearest Edge POP.

If the Edge Bloom Filter bit is 0, return available: true in <1ms. If 1, check regional Redis (taken:<handle>).

Stage 2 - Global Read Path

Three-Tier Availability Check

Edge GatewaysourceEdge Bloom FilterrouterRedis NegativeCachecacheGeo Read ReplicastorageOn bit=1

1.No Consensus on Reads: Availability checks tolerate 500ms staleness; Raft serializes the actual claim.

2.Alternative Generator: If taken, suggest 3 variants (e.g., @alice_92) batch-checked in 1 Redis pipeline.

Three-tier edge filtering serves 99% of availability checks without touching any database.

Engineering Decision Framework
Problem
How to implement Design a Globally Unique Username & Identity Claim Service without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
When nodes partition or reboot past retry windows, serve 500K/s checks from Edge Bloom Filters + Redis negative caches, and serialize 5K/s claims via CockroachDB/Spanner Raft range leases with an Idempotent Outbox and Cooldown Graveyard.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Design a Globally Unique Username & Identity Claim Service experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
intermediate

Write Path: Canonicalizer, Profanity Trie & Blocklist.

Why this matters: Filter invalid, spoofed, and offensive handles deterministically before consensus.

Think of Write Path: Canonicalizer, Profanity Trie & Blocklist as the intuition layer for Design a Globally Unique Username & Identity Claim Service: Filter invalid, spoofed, and offensive handles deterministically before consensus.

Claim requests first run NFKC + UTS #39 homoglyph folding + length/regex validation (^[a-z0-9_]{3,20}$). Next, an in-memory Aho-Corasick Trie (~5ms) checks 50,000+ profanity substrings and reserved system names (admin, support, api, root) in O(len(handle)) time, rejecting invalid claims with 422 Unprocessable Entity before touching Raft.

Stage 3 - Pre-Write Screening

Canonicalizer & Aho-Corasick Filter

Claim RequestsourceUnicodeCanonicalizerprocessorAho-Corasick TrierouterValid Canonical KeysinkO(N) multi-pattern scan

1.Versioned Blocklist: Push blocklist updates via config pub/sub without restarting claim services.

2.Audit Display vs Canon: Preserve user's chosen capitalization in display_handle.

O(N) Aho-Corasick screening rejects spoofed and reserved handles before consensus.

04
intermediate

CockroachDB / Spanner Raft Range Leases.

Why this matters: Serialize concurrent global claims with linearizable single-key transactions.

The canonical key routes to the Raft range owning hash(canonical_handle).

The range's single Raft leaseholder executes INSERT INTO handles (canonical_handle, user_id, status, lease_exp, fence_token) VALUES (...) ON CONFLICT (canonical_handle) DO NOTHING RETURNING fence_token (or updates an expired PENDING/COOLDOWN row).

Stage 4 - Consensus Commit

CockroachDB / Spanner Raft Leaseholder

US Claim WorkersourceEU Claim WorkersourceRaft Range LeaderrouterQuorum WAL CommitstorageConditional INSERT

1.Regional Placement: Place Raft replicas in US-East, US-Central, and EU-West for ~60ms quorum RTT.

2.Bounded Retries: On transient Raft lease-transfer errors, retry with exponential backoff + jitter.

Per-range Raft leaseholders guarantee global linearizability with ~60ms quorum latency.

05
intermediate

Idempotent Outbox & Cross-Region Cache Invalidation.

Why this matters: Propagate committed claims to Auth/Profile services and Edge Bloom Filters reliably.

Think of Idempotent Outbox & Cross-Region Cache Invalidation as the intuition layer for Design a Globally Unique Username & Identity Claim Service: Propagate committed claims to Auth/Profile services and Edge Bloom Filters reliably.

Inside the same Raft transaction, a row inserts into identity_outbox(event_id, canonical_handle, user_id, fence_token, type). A CDC relay publishes to Kafka, driving two consumers: (1) downstream Profile/Search services (idempotently checking fence_token), and (2) Global Cache Invalidation updating regional Redis + Edge Bloom Filters in <500ms.

Stage 5 - Outbox & Sync

Transactional Outbox & Edge Invalidation

Raft ACID TxnstorageCDC Outbox RelayprocessorGlobal Cache SynccacheProfile / Auth SyncsinkSet Redis/Bloom <500ms

1.No Dual-Write Bugs: Writing handle + outbox in one ACID transaction guarantees zero lost events.

2.Idempotent Consumers: Downstream services track last_fence_token per user_id.

Transactional outboxes bridge linearizable identity commits to global eventual caches.

06
advanced

Cooldown Tombstone Graveyard & Account Deletion.

Why this matters: Lock retired handles for 90 days on rename and permanently on account bans.

On rename (@old -> @new), one ACID transaction claims @new and updates @old to status = 'COOLDOWN', locked_until = now() + 90 days, owner_id = user_id.

Other users attempting to claim @old receive 409 Conflict until now() > locked_until.

Stage 6 - Cooldown Graveyard

Atomic Rename & 90-Day Lock

Atomic Rename TxnprocessorCOOLDOWN (90 Days)storagePERMA_LOCKEDcacheReleased After 90dsinkLock permanently if banned

1.Atomic Swap: Claiming @new and locking @old in one transaction ensures a user is never handle-less.

2.Rate-Limit Renames: Limit handle renames to once per 30 days to prevent churn abuse.

Single-transaction rename swaps and 90-day cooldowns prevent handle hijacking.

07
advanced

Chaos Resilience, Quorum Loss & Nightly Bloom Rebuild.

Why this matters: Maintain read availability during regional outages and prevent Bloom false-positive drift.

Think of Chaos Resilience, Quorum Loss & Nightly Bloom Rebuild as the intuition layer for Design a Globally Unique Username & Identity Claim Service: Maintain read availability during regional outages and prevent Bloom false-positive drift.

If a continent loses connectivity to the Raft quorum majority, writes in the minority partition fail fast with 503 Service Unavailable (CP behavior—never compromising uniqueness), while 500K RPS availability reads continue uninterrupted from local Edge Bloom Filters and Redis. Nightly Spark/Flink jobs snapshot active + cooldown handles into fresh Edge Bloom Filters.

Stage 7 - DR & Maintenance

Partition Behavior & Bloom Rebuild

Network PartitionrouterWrites Fail-Closed503processorReads Stay 100% UpcacheNightly BloomRebuildsinkServe local reads

1.CAP Clarity: CP on identity claims (safety), AP on availability checks (UX).

2.Rolling Bitset Swap: Swap new Bloom filter bitsets atomically in Edge POPs with zero downtime.

Failing minority writes closed while keeping edge reads available embodies clean CAP design.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

During a transatlantic network partition isolating EU-West from the US-based Raft quorum majority, how must the Username Claim Service behave?

Recommended Learning Flow