Skip to main content
← CONCEPTS / DISTRIBUTED-SYSTEMS
An end-to-end domain learning journey

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.
Start the journey7 sections· Last modified Nov 24, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

If replicas diverge under asymmetric network delays, canonicalize first (NFKC + homoglyph folding), absorb read-heavy availability checks via Bloom filters + negative caches, and serialize mutations through linearizable Raft/Spanner range leases.

TL;DR30-second simplified summary
▾

The service separates reads from writes: 500K RPS availability checks hit Edge Bloom filters and Redis negative caches in <2ms, while 5K RPS claim writes serialize through Raft range leases (CockroachDB/Spanner) keyed by NFKC/homoglyph-folded canonical_handle.

A 10-minute PENDING_CLAIM lease protects handles during multi-step signup, and transactional outboxes issue monotonic fencing tokens to downstream services.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Idempotency & Deduplication
Idempotency keys and deduplication logs ensure that network retries, at-least-once message deliveries, and double-clicks execute state mutations at most once while returning the original cached outcome.
OpenID Connect Identity
An interoperable identity layer built on top of OAuth 2.0 that issues cryptographically signed JWT ID Tokens so applications can verify who a user is.
Full walkthrough · 7 stages
01
foundation

Unicode NFKC, Case Folding & Homoglyph Canonicalization.

Why this matters: Prevent visual spoofing and duplicate-looking usernames before hitting storage.

Think of Unicode NFKC, Case Folding & Homoglyph Canonicalization as the intuition layer for Globally Unique Identity Claim Consensus: Prevent visual spoofing and duplicate-looking usernames before hitting storage.

Without canonicalization, @аlice (Cyrillic а) and @alice (Latin a) are distinct UTF-8 bytes that look identical to humans. Every check and claim runs through a deterministic Canonicalizer: strip zero-width/invisible characters, apply Unicode NFKC, map confusable homoglyphs (UTS #39 skeleton) to ASCII equivalents, and lowercase—storing both display_handle and canonical_handle (UNIQUE).

Stage 1 - Canonicalization

UTS #39 & NFKC Normalizer

Raw Input '@Аlice'sourceNFKC + Strip ZWJprocessorHomoglyph Skeletonroutercanonical_handlesinkApply UTS #39 map

1.Dual Storage: Store canonical_handle as the UNIQUE primary key while preserving display_handle for UI.

2.Reserved Trie: Check an in-memory Aho-Corasick trie for profanity and reserved words like 'admin'.

Deterministic Unicode and homoglyph canonicalization stops impersonation before database writes.

02
foundation

Why Eventual Consistency Fails & Linearizable Quorum.

Why this matters: Understand why Dynamo/Cassandra LWW loses claims and why Raft/Paxos is required on writes.

Think of Why Eventual Consistency Fails & Linearizable Quorum as the intuition layer for Globally Unique Identity Claim Consensus: Understand why Dynamo/Cassandra LWW loses claims and why Raft/Paxos is required on writes.

In an eventually consistent AP store, US-East and EU-West both accept @alice locally; during async reconciliation, Last-Write-Wins silently deletes the earlier user's account handle! Uniqueness requires CP linearizability on writes: a single Raft/Paxos leaseholder for the key's shard serializes concurrent claims, guaranteeing at most one winner.

Stage 2 - Linearizability

Concurrent Claim Serialization via Raft

US-East: Claim'@alice'sourceEU-West: Claim'@alice'sourceRaft Range Leaderrouter1 Winner / 1 409ConflictsinkPropose INSERT

1.Single-Key Consensus: Uniqueness only needs linearizability per single key, scaling horizontally across Raft ranges.

2.409 Conflict: Return HTTP 409 with suggested available alternatives on contention.

Raft/Paxos consensus per key range guarantees exactly one winner under concurrent global claims.

Engineering Decision Framework
Problem
How to implement Globally Unique Identity Claim Consensus 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
If replicas diverge under asymmetric network delays, canonicalize first (NFKC + homoglyph folding), absorb read-heavy availability checks via Bloom filters + negative caches, and serialize mutations through linearizable Raft/Spanner range leases.
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 Globally Unique Identity Claim Consensus experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
intermediate

Bloom Filter & Redis Negative Cache for 500K RPS Reads.

Why this matters: Scale live 'is this username taken?' keystroke checks 100x higher than claim writes.

Sign-up forms fire availability checks on every keystroke, creating a 100:1 read-to-write ratio (500K RPS reads vs 5K RPS writes).

An Edge Bloom Filter (~600MB for 500M handles at 1% FP) answers 'definitely available' in <0.5ms.

Stage 3 - Read Scaling

Bloom Filter + Redis Availability Check

Keystroke ChecksourceEdge Bloom FilterrouterRedis Taken CachecacheDB Read ReplicastorageIf 1 -> check Redis

1.Eventual Reads OK: Stale reads on availability checks are harmless because the final write uses Raft.

2.Debounce Clients: Debounce UI keystroke checks (250ms) to cut redundant network traffic.

Edge Bloom filters absorb the vast majority of availability checks for unclaimed handles.

04
intermediate

Two-Phase Lease Reservation & Signup Funnel UX.

Why this matters: Hold a chosen username briefly while a user completes password/CAPTCHA/billing steps.

If @alice is free at step 1 of signup, losing it while typing a credit card at step 3 ruins UX.

A Two-Phase Lease Reservation writes a short-TTL (ttl = now + 10m) PENDING_CLAIM row keyed by (canonical_handle, reservation_token) in the Raft store.

Stage 4 - Lease Reservation

10-Minute Pending Claim Lease

Step 1: Pick'@alice'sourceRaft PENDING RowstorageStep 3: FinishSignuprouterAtomic PromoteACTIVEsinkVerify token & promote

1.Anti-Squatting: Rate-limit pending reservations per IP/device fingerprint to block handle hoarding.

2.Lazy Expiry: Any new claim on an expired PENDING row overwrites it atomically.

Short-TTL lease reservations protect handles during multi-step onboarding without permanent locks.

05
intermediate

Fencing Tokens & Saga Rollback Across Downstream Services.

Why this matters: Keep Identity, Auth, Profile, and Billing microservices consistent when claiming or renaming.

Claiming a username often spans multiple services (Identity DB -> Auth/OIDC -> Profile -> Search Index).

The Identity Consensus store issues a monotonic fencing_token alongside the commit, and writes an atomic IdentityClaimed row to a local Transactional Outbox table.

Stage 5 - Outbox & Saga

Transactional Outbox + Fencing Token

Identity CommitstorageTransactional OutboxprocessorDebezium / RelayrouterProfile & SearchSinkssinkStream to Kafka

1.Fencing Prevents Races: If a user renames quickly, downstream services reject out-of-order events with lower tokens.

2.Zero 2PC Needed: Outbox + Saga avoids fragile distributed two-phase commit across microservices.

Transactional outboxes and monotonic fencing tokens keep downstream services ordered without 2PC.

06
advanced

Cooldown Tombstone Graveyard & Anti-Impersonation.

Why this matters: Prevent immediate hijacking of recently released or renamed usernames.

If @bob renames to @bobby, immediately freeing @bob lets an attacker hijack @bob and impersonate him to followers/mentions.

Instead, renaming moves @bob into a Cooldown Tombstone Graveyard (status = COOLDOWN, locked_until = now + 90d).

Stage 6 - Cooldown Graveyard

90-Day Handle Cooldown Tombstone

User Renames HandlesourceTombstone GraveyardstorageAttacker Claims@bobrouterOriginal OwnerReclaimsinkReject with 409

1.Deleted Accounts: Keep handles of banned or deleted accounts permanently tombstoned to stop impersonation.

2.Explicit History: Store handle_history(user_id, handle, retired_at) for auditability.

A 90-day cooldown graveyard prevents instant handle hijacking after renames.

07
advanced

Global Cache Invalidation & Split-Brain Recovery.

Why this matters: Propagate newly claimed handles to Edge Bloom Filters and Redis caches within milliseconds.

Think of Global Cache Invalidation & Split-Brain Recovery as the intuition layer for Globally Unique Identity Claim Consensus: Propagate newly claimed handles to Edge Bloom Filters and Redis caches within milliseconds.

When @alice commits in US-East, regional Redis negative caches in EU and APAC might briefly still say 'available' (harmless for correctness, slightly noisy for UX). An async Kafka -> Edge Pub/Sub stream pushes newly claimed handles to regional Redis and sets bits in Edge Bloom Filters within <500ms—while Bloom Filter rebuilds run nightly to clear expired reservations.

Stage 7 - Global Sync

Async Bloom & Redis Invalidation

Identity OutboxsourceGlobal Kafka MirrorprocessorRegional Redis +BloomcacheNightly BloomRebuildsinkUpdate Edge Bloom/Redis

1.Additive Bloom: Bloom filters support bit-setting on inserts; nightly rebuilds reclaim expired bits.

2.Graceful Degradation: If Edge Redis is unreachable, availability checks fall back to DB read replicas.

Cross-region outbox streams update Edge Bloom filters and Redis caches in under 500ms.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why must a Globally Unique Username Service use a CP linearizable store (like Raft/Spanner) on writes instead of an AP Last-Write-Wins (LWW) store?

Recommended Learning Flow