{}DSA Atlas

Data at Scale — Storage Choices, Search, Blobs, CDNs & Multi-Region

A decision guide for picking data stores, replication and sharding in practice (resharding, hot partitions, cross-shard queries), full-text search with inverted indexes, object storage and large uploads, CDNs, data pipelines and CDC, and multi-region active-passive vs active-active designs.

Advanced6 interview questions

A decision guide for storage

what is the data? files / media structured records text to search metrics / events hot ephemeral S3 + CDN Elasticsearch Kafka → TSDB/OLAP Redis need joins / ACID? yes → PostgreSQL/MySQLscale: NewSQL / Vitess no, huge write volume, key access→ Cassandra / DynamoDB
Most real systems are polyglot: one source of truth plus derived stores.

Replication and sharding in practice

Recap of the theory in DBMS: distributed data; here are the practical concerns.

ProblemSolutions
Choosing a shard keyhigh cardinality, even distribution, matches the dominant query (user_id, tenant_id)
Hot partition (celebrity, viral item)key salting (key#0..9) and scatter-gather reads, dedicated shards for big tenants, caching
Cross-shard queriesdenormalise, global secondary indexes, scatter-gather with limits, or a separate analytics store
Cross-shard transactionsavoid by co-locating related data (same shard key); otherwise sagas or a distributed SQL DB
Reshardingmany logical shards → few physical; online migration via CDC/dual write + backfill + verify + cutover
Global uniquenessSnowflake IDs, UUIDv7, or a uniqueness table keyed by the unique value
Replication lagread-your-writes routing, monotonic reads (sticky replica), lag-aware load balancing

Zero-downtime migration recipe

  1. Dual-write (or CDC stream) to old and new stores.
  2. Backfill history in batches (idempotent upserts).
  3. Verify: row counts, checksums, shadow reads comparing results.
  4. Gradually move reads (feature flag, 1% → 100%).
  5. Stop writes to old store; keep it for rollback; finally decommission.
documents d1: "red running shoes"d2: "blue running jacket"d3: "red jacket" inverted index red → [d1, d3]run → [d1, d2] (stemmed)shoe → [d1]blue → [d2]jacket → [d2, d3]
Query "red jacket" = intersect posting lists → d3, then rank with BM25.

Architecture: DB → CDC → Kafka → indexer → Elasticsearch (sharded, replicated) ← search API. Reindex for mapping changes into a new index and atomically swap an alias. Typeahead uses prefix structures (edge n-grams, tries, completion suggesters) — see the typeahead case study.

Object storage and uploads

client upload API object storage (S3) event → queue scan · transcode metadata DB 1 request URL 2 row: pending 3 PUT parts 4 status: ready
Bytes go straight to storage; the API only handles metadata and authorisation.

Object storage facts: 11 nines durability (S3), flat key namespace, strong read-after-write consistency on S3, storage classes (standard → infrequent access → archive), lifecycle rules, versioning, cross-region replication.

CDNs

ConceptDetail
Push vs pullpull (origin fetched on miss) is the default; push for large pre-known assets
Cache keysURL + selected headers/cookies; avoid variance explosion
Invalidationversioned/fingerprinted URLs (app.3f9a.js) beat purges
Origin shieldan extra tier so a miss storm hits the origin once
Dynamic accelerationTLS termination near users + persistent connections to origin
Edge computeWorkers/Lambda@Edge for auth, A/B, personalisation
Signed URLs/cookiesprotect paid or private content

Data pipelines

OLTP DBs CDC (Debezium) Kafka stream (Flink) lake (S3/Iceberg) warehouse / BI
Batch (ETL/ELT) and streaming paths feeding analytics; "Kappa" uses only the stream.

Lambda architecture = batch layer (accurate, slow) + speed layer (approximate, fast). Kappa = one streaming pipeline, replay the log to recompute. Modern lakehouses (Iceberg/Delta/Hudi tables on S3) add ACID and time travel to the lake.

Multi-region

Active-passive us-eastreads + writes eu-weststandby replica async replication · failover in minutes Active-active us-eastreads + writes eu-westreads + writes conflicts: home region, CRDT, or Spanner global routing: GeoDNS / anycast + health checks decide which region serves a user
Multi-region trades cost and consistency complexity for latency and resilience.
StrategyRPORTOComplexity
Backup & restorehourshourslow
Pilot lightminutestens of minutesmedium
Warm standby (active-passive)seconds–minutesminutesmedium
Active-active~0~0high

Interview questions

0 / 6 marked confident

Answer out loud first, then open the model answer. Mark a question confident only when you could explain it to an interviewer without notes.