Scalability: Horizontal and Vertical Scaling, Sharding and Partitioning Interview Questions
261 multiple-choice tech interview questions on Scalability: Horizontal and Vertical Scaling, Sharding and Partitioning: scale up vs scale out, statelessness and autoscaling, replication, partitioning and sharding strategies, consistent hashing, hot spots and rebalancing. Written for technical phone screens and interview prep, organized by subtopic, with a short explanation for every answer. Learn the 73 key terms with the flashcards first, then test yourself.
Take the practice test · Flashcards · All study tools
What it covers
- 4.1 Scaling fundamentals and the laws that limit it
- 4.2 Capacity planning and estimation
- 4.3 Load testing and finding bottlenecks
- 4.4 Stateless tiers, load balancing and autoscaling
- 4.5 Scaling relational databases before sharding
- 4.6 Sharding strategies and shard keys
- 4.7 Consistent hashing, rebalancing and resharding
- 4.8 Hot spots, cross-shard work and global IDs
- 4.9 Async work, multi-tenancy and global scale
Key terms
4.1 Scaling fundamentals and the laws that limit it
- Vertical scaling
- Adding resources to one machine (scale up)
- Horizontal scaling
- Adding more machines or instances (scale out)
- Autoscaling
- Automatically adding or removing capacity based on metrics
- Amdahl's law
- Speedup from parallelism is limited by the serial part of the work
- Universal Scalability Law
- A model where contention and coherency limit scaling
- Contention
- Waiting for shared resources like locks
- Coherency cost
- Work spent keeping nodes' shared state in sync
- Scale cube
- AKF's three axes of scaling: clone, split by function, split by data
- Linear scalability
- Throughput rising in proportion to resources
- Retrograde scaling
- Throughput falling as more nodes are added
- Serial bottleneck
- A step that can't run in parallel and caps speedup
4.2 Capacity planning and estimation
- Capacity planning
- Making sure enough resources exist for expected demand
- Peak-to-average ratio
- How much higher the busiest period is than the mean
- Demand driver
- A business metric that drives system load
- Capacity model
- A mapping from demand drivers to needed resources
- N+1 capacity
- Enough capacity to carry peak load with one node lost
- Seasonality
- Repeating demand patterns like holiday peaks
- Growth rate
- How fast demand rises over time
- Capacity per instance
- The most load one instance can handle
4.3 Load testing and finding bottlenecks
- Load test
- Running expected traffic to check performance
- Stress test
- Pushing past expected load to find limits
- Soak test
- Running steady load for a long time to find leaks
- Spike test
- A sudden load jump to check the reaction
- Open workload model
- Requests arriving at a set rate regardless of replies
- Saturation
- Work queued because a resource is full
- Latency knee
- The load where latency starts climbing sharply
- Bottleneck shifting
- A new limit appearing once one is fixed
4.4 Stateless tiers, load balancing and autoscaling
- Stateless tier
- Servers that keep no client state between requests
- Target tracking scaling
- Scaling to keep a metric near a target value
- Cooldown
- A wait after scaling so metrics can settle
- Horizontal Pod Autoscaler
- Kubernetes controller that changes replica counts
4.5 Scaling relational databases before sharding
- Functional partitioning
- Splitting features' data into separate databases
- Read/write splitting
- Sending writes to the primary and some reads to replicas
- Archiving
- Moving old rows out of hot tables
- Load leveling
- Using a queue to smooth bursts of work
- Compute-storage separation
- Scaling a database's storage and compute independently
4.6 Sharding strategies and shard keys
- Sharding
- Splitting data across multiple servers by a shard key
- Shard key
- The attribute that decides which shard stores a row
- Hot spot
- A shard or partition receiving disproportionate load
- Shard routing
- Finding which shard holds a given key
- Vitess
- A sharding and routing layer for MySQL
- Citus
- A PostgreSQL extension for distributed tables
- Reference table
- A small table copied to every node
- Co-location
- Placing related tables' rows for one key on the same node
- Logical shard
- A unit of data that can be moved between servers
- Compound shard key
- A shard key made of several fields
- Shard map
- The record of which keys live on which shard
- Geographic sharding
- Splitting data by user region
4.7 Consistent hashing, rebalancing and resharding
- Hash ring
- A circle of hash values where nodes and keys are placed
- Rendezvous hashing
- Picking the node with the highest score for each key
- Jump consistent hash
- A fast, memory-free hash mapping keys to numbered buckets
- Bounded-load hashing
- Consistent hashing that caps each node's load
- Hash slot
- A fixed bucket of keys that moves between nodes
- Range split
- Breaking a busy or large key range into smaller ones
- Cutover
- Switching traffic from old shards to new ones
4.8 Hot spots, cross-shard work and global IDs
- Consistent hashing
- Hashing scheme where adding or removing nodes moves few keys
- Resharding
- Moving data between shards to rebalance or grow
- Scatter-gather
- Sending a query to many shards and merging the results
- Aggregation pushdown
- Computing partial results on each shard
- Broadcast query
- A query that must run on every shard
- Global index
- An index mapping a non-shard key to a shard
- Ticket server
- A central database handing out unique IDs
- Key splitting
- Spreading one hot key over several sub-keys
- Affinity
- Routing related work to the same place
- Hot key detection
- Tracking per-key request rates to find hot spots
4.9 Async work, multi-tenancy and global scale
- Background job
- Work done outside the user's request
- MapReduce
- Parallel map over pieces, then combine with reduce
- Pool model
- Tenants sharing the same resources
- Silo model
- Each tenant getting dedicated resources
- Tenant quota
- A per-tenant limit on resource use
- Edge compute
- Running code at CDN locations near users
- Precomputation
- Building results ahead of time for cheap reads
- Arrival-rate test
- A load test sending requests at a set rate
Sample practice questions
What is vertical scaling?
- Adding more machines behind a load balancer
- Splitting a database's rows across several servers
- Moving the workload into a different cloud region
- Giving one machine more CPU, memory or faster disks
Answer: D. Giving one machine more CPU, memory or faster disks It is simple but has a hard ceiling, often needs downtime, and keeps a single point of failure.
Traffic averages 200 requests per second with a 5x peak ratio. What peak should you plan for?
- About 200 per second
- About 40 per second
- About 1,000 per second
- About 5,000 per second
Answer: C. About 1,000 per second Average × ratio, then add headroom.
What's a load test?
- Running expected traffic to check speed and errors
- Counting how many files a disk can hold
- Measuring how heavy a server rack is
- Testing that a page loads in a browser once
Answer: A. Running expected traffic to check speed and errors At normal and peak levels.
What does autoscaling need to work well for a web tier?
- Stateless instances, health checks, a good metric and fast startup
- One single large server that's sized for the very highest peak
- Sticky sessions stored in each instance's local memory
- A manual approval step before every single scale event
Answer: A. Stateless instances, health checks, a good metric and fast startup Scale on signals like CPU, request rate or queue length, with cooldowns to avoid flapping.
Which component is usually hardest to scale horizontally?
- A tier of stateless web servers behind a balancer
- A stateful relational database handling writes
- A content delivery network serving cached files
- Static file hosting in cloud object storage
Answer: B. A stateful relational database handling writes Writes require coordination; reads can be scaled with replicas and caches more easily.
What is the difference between partitioning and sharding?
- Sharding splits a table's columns, while partitioning splits its rows instead
- Partitioning splits data, maybe on one server; sharding spreads it across servers
- They're unrelated techniques that solve completely different problems
- Partitioning always requires multiple databases, while sharding never does
Answer: B. Partitioning splits data, maybe on one server; sharding spreads it across servers The terms are often used interchangeably, but sharding implies distribution across nodes.
What problem does consistent hashing solve?
- Adding or removing nodes moves only a few keys, unlike hash mod N
- It makes the hash function cryptographically secure against attacks
- It sorts every key alphabetically so range queries stay on one node
- It guarantees that no hot spots can ever form on any of the nodes
Answer: A. Adding or removing nodes moves only a few keys, unlike hash mod N DynamoDB, Cassandra and many caches use consistent hashing, often with virtual nodes.
In a multi-tenant SaaS app sharded by tenant ID, what problem can one very large tenant cause?
- Every tenant on the platform loses some of their data permanently
- Queries become completely impossible for every tenant on that shard
- A hot shard much busier than the rest, which may need its own shard
- Sharding stops working for every tenant, so the database must merge
Answer: C. A hot shard much busier than the rest, which may need its own shard Directory-based sharding makes it easy to move big tenants.
Why move slow work like sending emails out of the request path?
- Background jobs never fail
- It makes emails arrive instantly
- Requests return fast; workers scale separately
- Emails can't be sent from web servers
Answer: C. Requests return fast; workers scale separately Queue it.
What is horizontal scaling?
- Upgrading the existing server to a bigger instance size
- Adding more columns to the busiest database table
- Adding more instances and spreading the load across them
- Raising the number of threads in each process
Answer: C. Adding more instances and spreading the load across them It can grow almost without limit and adds redundancy, but needs stateless services or data partitioning.
More Architecture
- System Design Interview Fundamentals
- Monoliths vs Microservices
- Event-Driven Architecture
- CAP Theorem and Distributed Consistency
- High Availability and Fault Tolerance
- API Gateways and Service Meshes
- Domain-Driven Design
- Clean and Hexagonal Architecture
- Security Architecture: Zero Trust and OWASP Top 10
- AI and LLM Integration: RAG, Prompts and APIs