Scalability
64 bites tagged Scalability — interview questions with model answers, and 60-second explainers.
Sampling 5% of users for a one-time survey
Hash user ID for the 5% gate, persist a 'shown' flag, race-safe single display. Deterministic sampling plus durable seen-state at scale.
Prepare for a launch traffic spike
Model expected load, load-test to find the first bottleneck, scale and cache, add graceful degradation and a queue for spiky writes. capacity planning for a known surge. turning up autoscaling without finding the bottleneck.
Session-based versus token-based authentication
Sessions store server-side state with a cookie id, tokens carry self-contained claims with no server store, weigh revocation versus scalability, especially across services. auth architecture trade-offs.
When horizontal scaling is the wrong fix
Adding instances fails when the bottleneck is a shared resource like one database, a lock, or a queue, so more instances just add contention; investigate where time is actually spent. Scaling judgment.
Scaling Prometheus for HA and volume
Shard scraping, add long-term object storage and global query via Thanos/Cortex/VictoriaMetrics, run redundant replicas for HA, with dedupe. scaling a single Prometheus past its limits.
High cardinality in time-series databases
Each combination is a separate series consuming memory and index; manage by avoiding unbounded labels and bucketing values. knowing cardinality equals number of unique label combinations.
Choosing a good shard key and avoiding hot spots
High cardinality, even write distribution, query alignment; monotonic keys send all writes to one shard. shard-key design tradeoffs. optimizing only for cardinality while ignoring write skew, or claiming any unique key works.
Read replica vs Multi-AZ in RDS
Multi-AZ is synchronous standby for failover, read replicas are async copies for read throughput, and the two solve different problems. separating high availability from read scaling. claiming a Multi-AZ standby serves reads.
Connection pooling and its key parameters
Reuse open connections to skip costly handshakes; tune max pool size and connection timeout. pooling tradeoffs. setting max size huge, exhausting database connections, or treating the pool as free.
Mitigating a database shard hot spot
Short-term, add read replicas or cache the hot keys; long-term, fix the partition key with hashing, salting, or finer-grained splitting. load-distribution remedies. only adding hardware without addressing the skewed key.
Range-based vs hash-based sharding trade-offs?
Range sharding keeps ordered keys together, great for range scans but prone to hot spots on sequential keys; hash sharding spreads keys evenly, avoiding hot spots but killing efficient range… choosing a shard strategy by query pattern.
What is sharding and why shard over vertical scaling?
Sharding splits one dataset across servers by a shard key so each holds a subset; you shard because vertical scaling hits hardware ceilings, gets costly, and remains a single point of failure. horizontal partitioning rationale.
What is database replication and why use it?
Replication keeps copies of data on multiple servers; primary benefits are high availability through failover and improved read scalability by spreading reads. basics of copying data across nodes.
Why fit Cassandra to a high-read, high-write workload?
Consistent-hash partitioning spreads load, replication and no single master give availability, log-structured writes are fast, tunable consistency balances per query. mapping Cassandra's masterless architecture to throughput needs.
Embed or reference likes in a document database?
Embedding is fast for small bounded lists but unbounded likes hit document size limits; referencing scales for high-cardinality, write-heavy likes. document modeling driven by access patterns and growth.
Shard key impact on uniqueness and cross-shard lookups
Uniqueness and FKs hold only within a shard; non-shard-key lookups need scatter-gather or a secondary index. understanding constraints break across shards. assuming a global unique index just works across shards.
Explain the inverted triangle of ITCSS
ITCSS orders layers from far-reaching low-specificity (settings, tools, generic) down to localized high-specificity (components, utilities), so specificity climbs gradually. managing the cascade at scale.
Design a programmatic SEO landing-page system
Structured data plus templates, genuinely unique per-page data, static build-time generation, quality gates and indexation control. programmatic SEO and thin-content avoidance. near-identical pages that swap one variable.
High-throughput serverless stream processing
Partition by key for per-user ordering, use a sharded log with batched consumers for backpressure, and tune batch size and shards for cost. stream design at scale. a global FIFO queue or per-event invocation at 100k/sec.
Serverless functions with a relational database
Concurrent function instances each open connections and exhaust the database's bounded pool; fix with a connection proxy or pooler, init-phase reuse, or capped concurrency. the connection-storm problem. a connection per call.
Scalability vs elasticity in the cloud
Scalability is the ability to handle more load by adding capacity; elasticity is automatically adding AND removing capacity in real time to match demand. a precise distinction often blurred.
Modularizing a monolithic iOS app
Extract low-dependency, high-reuse leaf code first behind clear interfaces, enforce boundaries, iterate inward. incremental modularization strategy.
Design a centralized experimentation service
A config/assignment API, deterministic SDK-side bucketing, and a separate exposure-logging pipeline. platform thinking for shared experimentation.
Head-based vs tail-based trace sampling
Head decides up front (cheap, may miss rare errors); tail decides after the trace completes (catches errors and slow traces but needs buffering). trace sampling trade-offs. claiming one is universally better.
Get Scalability bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.