Blog
50 Scalability & System Design Interview Questions
- February 6, 2026
- Posted by: InterviewExpert.org
- Category: Backend Interview Preparation System Design
Core Scalability Concepts
1. What is scalability? Explain horizontal vs. vertical scaling.
Scalability is the ability of a system to handle increased load (users, traffic, data) by adding resources without performance degradation. Horizontal scaling is preferred for large-scale, high-availability systems.
Vertical Scaling (Scale Up)
- Add more power to a single machine (CPU, RAM, Disk)
- Example: Upgrade server from 8GB RAM to 64GB
Pros
- Simple to implement
- No code changes
Cons
- Hardware limit
- Single point of failure
- Expensive
Horizontal Scaling (Scale Out)
- Add more machines and distribute load
- Example: Add multiple servers behind a load balancer
Pros
- High availability
- No hard limit
- Cost-effective at scale
Cons
- More complex (distributed systems, data consistency)
2. How would you design a system that scales from 1 to 10 million users?
3. What are the pros/cons of vertical vs. horizontal scaling?
Vertical scaling is good initially, horizontal scaling is required at scale.
| Aspect | Vertical Scaling | Horizontal Scaling |
|---|---|---|
| Complexity | Low | High |
| Cost | Expensive | Cost-effective |
| Availability | Low | High |
| Scalability | Limited | Virtually unlimited |
| Failure Impact | High | Low |
4. Explain the Scale Cube and how it applies to system scaling.
Modern systems usually use all three dimensions together. The Scale Cube describes three independent scaling dimensions:
X-Axis: Horizontal Duplication
- Add identical instances
- Example: Multiple app servers
Y-Axis: Functional Decomposition
- Split system by services
- Example: User Service, Order Service
Z-Axis: Data Partitioning (Sharding)
- Split data by key
- Example: Users by region or userId
5. What is the CAP theorem and why is it important?
CAP Theorem states that a distributed system can guarantee only two of:
- Consistency (C) – All users see same data
- Availability (A) – System always responds
- Partition Tolerance (P) – System works despite network failures
Since network failures are unavoidable, systems choose between:
- CP: Strong consistency (e.g., banking)
- AP: High availability (e.g., social media)
6. How do you estimate capacity and load before designing a scalable system?
I start by identifying business goals and usage patterns, such as daily active users, peak concurrent users, and request types. Then I estimate traffic (RPS/QPS), data size, and read–write ratios. I calculate peak load (usually 2–5× average), estimate storage growth, and define latency and availability targets (SLAs).
Based on these numbers, I size servers, databases, cache, and network capacity, and leave headroom for future growth.
Steps:
- Estimate users
- Daily active users (DAU)
- Estimate requests
- Requests per user per day
- Calculate QPS
QPS = (Total requests per day) / 86400
- Estimate data size
- Storage per user × users
- Add buffer
- 2× or 3× for traffic spikes
7. When would you choose microservices over monoliths for scalability?
Choose microservices when:
- Teams need independent deployments
- Different components scale differently
- System is large and evolving
- High availability is required
Choose monolith when:
- Small team
- Early-stage product
- Simpler operations
8. Explain the trade-offs between consistency and availability in distributed systems.
The choice depends on business requirements.
- Consistency
- Users always see latest data
- Slower during failures
- Availability
- System always responds
- Data may be slightly stale
Examples
- Banking → Consistency first
- Social media → Availability first
9. What are common scalability bottlenecks, and how would you identify them?
Databases are usually the first scalability bottleneck.
Common Bottlenecks
- Database (single instance)
- Network latency
- CPU / memory limits
- Synchronous calls
- Lock contention
Identification Methods
- Load testing
- Metrics & monitoring
- Distributed tracing
- Profiling
10. How does auto-scaling work in cloud environments (AWS/GCP/Azure)?
Auto-scaling ensures performance while optimizing cost. In cloud platforms like Amazon Web Services, Google Cloud Platform, and Microsoft Azure:
Auto-scaling process:
- Monitor metrics (CPU, memory, QPS)
- Define scaling rules
- Automatically add/remove instances
- Load balancer routes traffic
Benefits:
- Cost efficient
- Handles traffic spikes
- No manual intervention
Load Handling & Traffic Management
1. Design a load balancer for a high-traffic web service.
High-level design:
- Client → DNS → Load Balancer → App Servers
- Load balancer distributes traffic across multiple stateless servers
Key components:
- Algorithms: Round-robin, least connections, weighted
- Health checks: Remove unhealthy instances
- TLS termination: Offload SSL
- Auto-scaling: Add/remove backend servers dynamically
2. How do proxies (forward/reverse) help scalability?
Reverse proxies are critical for scaling backend services.
Forward Proxy
- Sits between client and internet
- Used for caching, filtering, anonymity
- Example: Corporate proxy
Reverse Proxy
- Sits between client and servers
- Used for load balancing, caching, security
- Example: Nginx, Envoy
Scalability benefits:
- Reduces backend load via caching
- Hides internal architecture
- Enables horizontal scaling
3. What are sticky sessions and when should they be used?
Sticky sessions (session affinity) ensure that a user’s requests are always routed to the same backend server by a load balancer. They are used when session data is stored in server memory and cannot be easily shared, such as in legacy or stateful applications.
However, they reduce scalability and fault tolerance, so stateless sessions or centralized session stores (like Redis) are preferred at scale.
4. What’s the difference between an API gateway and a load balancer?
Load balancers distribute traffic, API gateways manage APIs.
| Aspect | Load Balancer | API Gateway |
|---|---|---|
| Level | Infrastructure | Application |
| Routing | Instance-level | API/service-level |
| Features | Health checks | Auth, rate limit, transform |
| Awareness | Protocol-level | Business-level |
5. How would you handle sudden traffic spikes?
I design for burst traffic, not just average traffic.
Strategies:
- Auto-scaling
- Caching (Redis, CDN)
- Rate limiting
- Graceful degradation
- Queue-based processing
6. How would you design global load balancing across regions?
Global load balancing improves both latency and resilience.
Design:
- Use Geo-DNS to route users to nearest region
- Each region has its own load balancer
- Data replicated across regions
Benefits:
- Low latency
- Disaster recovery
- High availability
7. What metrics would you monitor for scalability (latency, throughput)?
Latency tells user experience; throughput tells system capacity.
Core metrics:
- Latency: p95 / p99 response time
- Throughput: Requests per second (RPS)
- Error rate: 4xx / 5xx
- Resource usage: CPU, memory
- Queue length
8. How to design rate limiting for millions of concurrent users?
Rate limiting protects systems from abuse and cascading failures.
Techniques:
- Token Bucket (most common)
- Leaky Bucket
- Fixed window / Sliding window
Implementation:
- Centralized store (Redis)
- Keyed by user/IP/API key
- Enforced at API gateway
9. What strategies exist for graceful degradation under heavy load?
Graceful degradation ensures that a system remains stable and usable even when resources are under stress. Common strategies include:
- Feature Shedding
Temporarily disable non-critical features such as recommendations, analytics, or background jobs to preserve core functionality. - Load Shedding
Reject or throttle excess requests early using rate limiting to protect critical services from overload. - Timeouts and Circuit Breakers
Apply timeouts and circuit breakers to prevent slow or failing dependencies from causing cascading failures. - Caching and Stale Data Serving
Serve cached or slightly outdated data instead of failing requests, reducing load on databases and downstream services. - Asynchronous Processing
Move non-urgent operations (emails, notifications, reports) to queues for delayed processing. - Priority-Based Request Handling
Ensure high-priority users or critical operations are handled first during peak load.
10. How do CDN and edge caching improve scalability?
CDNs and edge caching improve scalability by serving content closer to users, reducing latency and offloading traffic from origin servers.
By caching static and frequently accessed content (images, CSS, JS, APIs) at edge locations, they dramatically reduce backend load, handle traffic spikes efficiently, and improve availability during peak usage or failures. This allows the core system to scale more easily and focus on dynamic, business-critical requests.
Data Storage & Database Scaling
1. How would you scale a database for billions of records?
To scale a database for billions of records, multiple strategies are applied together to ensure performance, availability, and reliability:
- Horizontal Scaling (Sharding)
Split data across multiple databases based on a shard key (e.g., user ID, region) so no single database becomes a bottleneck. - Read Replicas
Use read replicas to distribute read-heavy traffic and reduce load on the primary database. - Index Optimization
Create efficient indexes on frequently queried fields to speed up reads while balancing write performance. - Caching Layer
Introduce caching (Redis/Memcached) to serve frequently accessed data and minimize database hits. - Data Partitioning & Archival
Partition large tables and move old or infrequently accessed data to cold storage. - Polyglot Persistence
Use different databases for different needs (SQL for transactions, NoSQL for large-scale reads or logs). - Asynchronous Writes & Batching
Batch writes and use async processing to handle high write throughput efficiently. - Monitoring & Capacity Planning
Continuously monitor performance metrics and plan capacity ahead to prevent hotspots.
2. When and how do you implement sharding?
When to implement sharding:
Sharding is introduced when a single database cannot handle growth despite optimizations.
Key indicators:
- Data size grows to hundreds of millions or billions of records
- High write throughput causes lock contention
- Query latency increases even with indexes and caching
- Storage or CPU limits are reached on a single database
How to implement sharding:
Sharding horizontally partitions data across multiple databases.
Implementation steps:
- Choose a shard key (user ID, tenant ID, region)
- Apply a sharding strategy:
- Range-based sharding (ID or time ranges)
- Hash-based sharding (uniform load distribution)
- Directory-based sharding (lookup service)
- Use consistent hashing to reduce rebalancing cost
- Avoid cross-shard queries
- Plan resharding and migration with minimal downtime
3. What are the scalability challenges with SQL vs NoSQL?
Scalability Challenges: SQL vs NoSQL
SQL databases are strong in consistency and complex queries but face challenges when scaling horizontally. They typically scale vertically, which becomes expensive and limited at large scale.
Challenges with SQL:
- Horizontal scaling is difficult due to joins and ACID transactions
- Write bottlenecks on a single primary node
- Sharding complexity at the application level
- Schema rigidity slows rapid changes
NoSQL databases are designed for large-scale, distributed systems but introduce different trade-offs. They scale horizontally by default, making them suitable for massive workloads.
Challenges with NoSQL:
- Weaker consistency models (eventual consistency)
- Limited support for complex queries and joins
- Data duplication increases storage usage
- Operational complexity in managing distributed clusters
In practice, systems often use a hybrid approach, choosing SQL for transactional data and NoSQL for high-scale, read/write-heavy workloads.
4. Design a distributed cache (e.g., memcached/Redis).
A distributed cache is used to reduce database load, improve latency, and handle high traffic by storing frequently accessed data in memory. The design focuses on scalability, consistency, and fault tolerance.
Core design components:
- Cache cluster with multiple Redis/Memcached nodes
- Client-side or proxy-based sharding to distribute keys
- Consistent hashing to minimize rebalancing when nodes change
- Replication for high availability and failover
- TTL (Time-To-Live) to automatically expire stale data
Caching strategies:
- Cache-aside (lazy loading): application reads from cache, falls back to DB, then updates cache
- Write-through / Write-back: cache is updated on writes (used selectively)
- Eviction policies: LRU, LFU to manage memory pressure
Scalability & reliability considerations:
- Horizontal scaling by adding cache nodes
- Replication and failover (Redis Sentinel/Cluster)
- Monitoring hit ratio, latency, and memory usage
- Graceful degradation—fallback to DB if cache fails
5. How would you handle cache invalidation in a distributed cache?
Cache invalidation is critical to maintain data consistency while keeping performance high in a distributed system. The goal is to minimize stale data without overloading the database.
Common cache invalidation strategies:
- TTL-based expiration: automatically expire data after a fixed time to limit staleness
- Write-through / write-around: update or invalidate cache entries immediately on data writes
- Explicit invalidation: delete or update cache keys when underlying data changes
- Versioned keys: include a version or timestamp in the cache key to avoid serving stale data
Distributed system considerations:
- Use pub/sub or event-based invalidation to notify all cache nodes of changes
- Prefer eventual consistency where strong consistency is not required
- Implement fallback mechanisms to safely read from the database if cache misses occur
6. How do read replicas improve scalability?
Read replicas improve scalability by offloading read traffic from the primary database, allowing the system to handle a much higher number of read requests without impacting write performance. Overall, read replicas are a cost-effective way to scale databases while keeping the system responsive.
How they help:
- Read-write separation: write operations go to the primary DB, reads are served from replicas
- Horizontal scaling: add more replicas as read traffic grows
- Improved performance: reduced load lowers query latency
- High availability: replicas can serve reads if the primary is under stress
Key considerations:
- Replication lag may cause slightly stale reads
- Best suited for read-heavy workloads
- Not ideal for strong consistency use cases
7. What’s the role of asynchronous processing (queues) in scalability?
Asynchronous processing improves scalability by decoupling request handling from long-running or non-critical tasks, allowing systems to respond quickly even under heavy load.
How queues help scalability:
- Smooth traffic spikes: queues absorb sudden bursts without overwhelming services
- Non-blocking requests: user-facing APIs return fast while work is processed in the background
- Horizontal scaling: consumers can be scaled independently based on load
- Fault isolation: failures in background tasks don’t impact core user flows
Common use cases:
- Email and notification sending
- Payment processing and order workflows
- Analytics, logging, and report generation
Queues enable systems to stay responsive, resilient, and scalable as traffic grows.
8. Design a data partitioning strategy for multi-tenant data.
In a multi-tenant system, data partitioning is essential to ensure scalability, isolation, and performance as the number of tenants grows. The strategy depends on tenant size, access patterns, and isolation requirements.
Common partitioning strategies:
- Shared database, shared schema: all tenants share tables, partitioned by
tenant_id(cost-effective, simple to start) - Shared database, separate schema: each tenant has its own schema (better isolation, moderate scalability)
- Database-per-tenant: each tenant gets a separate database (strong isolation, easier scaling for large tenants)
Partitioning & scaling techniques:
- Use tenant_id as the partition or shard key to distribute data evenly
- Apply hash-based partitioning to avoid hotspots from large tenants
- Support tenant tiering (small tenants shared, large tenants isolated)
- Plan for tenant migration between partitions as usage grows
This approach balances cost, performance, and isolation, allowing the system to scale smoothly from a few tenants to thousands or millions.
9. How would you scale write-heavy workloads?
Write-heavy workloads require designs that maximize throughput, durability, and consistency while avoiding contention and bottlenecks.
Key strategies to scale writes:
- Database sharding: distribute writes across multiple shards using a good shard key
- Asynchronous writes: buffer writes using queues or logs to smooth traffic spikes
- Batching writes: group multiple write operations to reduce disk and network overhead
- Append-only / log-based storage: optimize for sequential writes
- Reduce write amplification: minimize indexes and secondary updates
Supporting techniques:
- Use NoSQL or log-based systems (e.g., event stores) for very high write rates
- Apply eventual consistency where strict consistency isn’t required
- Scale consumers and writers horizontally
These techniques help systems handle millions of writes per second reliably at scale.
10. What is hot partition / hot key problem and how do you solve it?
Hot Partition / Hot Key Problem and Its Solution
The hot partition (or hot key) problem occurs when a disproportionately large amount of traffic is routed to a single partition, shard, or key, causing performance bottlenecks and uneven resource utilization.
Why it happens:
- Poor partition/shard key selection
- Highly popular users, items, or tenants
- Time-based or sequential keys (e.g., latest data)
How to solve it:
- Key salting: add a random or hashed suffix to spread load across multiple partitions
- Better partitioning strategy: use hash-based or composite keys
- Dynamic re-sharding: split hot partitions at runtime
- Caching hot data: serve frequent reads from cache or CDN
- Request rate limiting: protect hot partitions from overload
By distributing traffic evenly and isolating hotspots, systems can maintain high performance and scalability even under skewed access patterns.
High-Level / Real Systems
1. Design a scalable notification service.
A scalable notification service must reliably deliver messages (push, email, SMS) to millions of users with low latency and high availability, while handling traffic spikes.
High-level design:
- Clients trigger notification requests via an API Gateway
- Requests are validated and pushed to a message queue
- Notification workers consume messages asynchronously
- Channel-specific services handle Email / SMS / Push
- External providers (FCM, APNs, SMS gateways) deliver messages
- Delivery status is stored for tracking and retries
Scalability strategies:
- Asynchronous processing with queues to absorb spikes
- Horizontal scaling of worker consumers per channel
- Rate limiting & batching to respect provider limits
- Retry with exponential backoff and dead-letter queues
- User preference & template caching to reduce DB reads
Reliability & optimization:
- Idempotent message handling to avoid duplicates
- Priority queues for critical notifications (OTP, alerts)
- Monitoring delivery success, latency, and failures
This design ensures the notification system remains fast, resilient, and cost-efficient at massive scale.
2. How would you design a system to support millions of concurrent users?
Designing a System to Support Millions of Concurrent Users
To support millions of concurrent users, the system must be designed for horizontal scalability, low latency, and fault tolerance from the start, while avoiding single points of failure.
Core design principles:
- Stateless application servers behind a load balancer to scale horizontally
- Auto-scaling groups to handle traffic fluctuations
- CDN and edge caching for static assets and frequently accessed data
- Distributed caching (Redis/Memcached) to reduce database load
Backend & data layer strategies:
- Read–write separation using read replicas
- Database sharding to distribute large datasets
- Asynchronous processing with queues for non-critical tasks
- Rate limiting to protect services from abuse
Reliability & observability:
- Health checks, retries, and circuit breakers for fault tolerance
- Monitoring, logging, and tracing to detect issues early
Together, these strategies allow the system to handle massive concurrency while remaining responsive and resilient.
3. Design a scalable push notification platform.
Design a Scalable Push Notification Platform
A scalable push notification platform must deliver messages to millions of devices reliably and in near real time, while handling spikes and ensuring high availability.
High-level architecture:
- Clients or services send notification requests via an API Gateway
- Requests are authenticated, validated, and placed into a message queue
- Notification processors/workers consume messages asynchronously
- Platform-specific services send notifications to APNs (iOS) and FCM (Android/Web)
- Delivery status and metadata are stored for tracking and retries
Scalability strategies:
- Asynchronous queues to absorb traffic bursts and decouple producers from consumers
- Horizontal scaling of workers based on queue depth
- Batching and rate limiting to comply with provider limits
- Caching user preferences, device tokens, and templates
- Sharding by app, region, or tenant to distribute load
Reliability & optimization:
- Retry with exponential backoff and dead-letter queues for failures
- Idempotency to avoid duplicate notifications
- Priority queues for critical alerts (OTP, security)
- Monitoring and alerts for latency, success rate, and provider errors
This design ensures the push notification platform is highly scalable, fault-tolerant, and efficient at massive scale.
4. How would you scale a real-time chat service?
How to Scale a Real-Time Chat Service
A real-time chat service must support low latency, high concurrency, and reliable message delivery while scaling to millions of users. The design focuses on efficient connection handling and horizontal scalability.
Core architecture & scaling approach:
- Use WebSockets or long-lived connections for real-time communication
- Deploy stateless chat servers behind a load balancer to scale horizontally
- Apply connection sharding (by user ID or room ID) to distribute active connections
- Use service discovery to route messages to the correct chat server
Message delivery & data handling:
- Use a message broker (Kafka/RabbitMQ/Redis Streams) to decouple senders and receivers
- Persist messages asynchronously to databases for durability
- Store recent messages in in-memory cache for fast access
- Use database sharding for chat history and large conversations
Reliability & performance optimizations:
- Handle offline users via push notifications and message queues
- Implement acknowledgements, retries, and idempotency
- Monitor connection count, message latency, and failures
- Apply rate limiting to prevent abuse and spam
This design ensures the chat service remains fast, reliable, and scalable even with millions of concurrent users.
5. Design a leaderboard system that supports millions of players.
A leaderboard system must support high write rates (score updates), fast reads (rank lookups), and real-time or near-real-time ordering while scaling to millions of players.
Core design approach:
- Use an in-memory data store (Redis) for fast ranking operations
- Maintain leaderboards using sorted sets (score → rank mapping)
- Separate write path (score updates) from read path (rank queries)
- Periodically persist data to a durable database for recovery and analytics
Scalability strategies:
- Sharding leaderboards by game, region, season, or time window
- Batching score updates to reduce write amplification
- Caching top-N results (e.g., Top 100/1000) for ultra-fast reads
- Use eventual consistency for non-critical rank freshness
Reliability & optimizations:
- Use idempotent updates to avoid duplicate score increments
- Apply rate limiting to prevent abuse or cheating
- Snapshot leaderboards periodically for fast recovery
- Support time-based leaderboards (daily/weekly/seasonal) to limit data size
This design ensures the leaderboard remains fast, scalable, and cost-efficient even with millions of active players and frequent score updates.
6. How would you design a distributed logging / analytics system?
A distributed logging and analytics system must ingest massive event volumes, process them reliably, and support fast querying and insights at scale.
High-level architecture:
- Applications generate logs/events and send them via agents or SDKs
- Logs are streamed into a message broker for buffering and durability
- Stream processors enrich, filter, and aggregate events
- Processed data is stored in search/analytics storage
- Dashboards and alerting systems query processed data
Scalability strategies:
- Asynchronous ingestion using queues/streams to handle spikes
- Horizontal scaling of consumers and processors
- Partitioning logs by service, tenant, or time
- Batching and compression to reduce storage and network cost
Storage & reliability considerations:
- Use time-based indexing for efficient queries and retention
- Apply hot–warm–cold storage tiers for cost optimization
- Support at-least-once delivery with replay capability
- Monitor ingestion lag, query latency, and storage growth
This design ensures the system remains scalable, fault-tolerant, and cost-efficient for large-scale logging and analytics workloads.
7. Design a scalable CDN or content distribution layer.
A scalable CDN delivers content close to users to reduce latency, offload origin servers, and handle massive traffic efficiently. The design focuses on edge caching, smart routing, and high availability.
Core architecture:
- Edge PoPs (Points of Presence) distributed globally to cache content near users
- Anycast DNS to route users to the nearest healthy edge
- Cache hierarchy (edge → regional → origin) to optimize hit rates
- Origin servers for cache misses and dynamic content
Scalability strategies:
- Aggressive caching of static assets (images, CSS, JS, videos)
- TTL tuning & cache invalidation (purge by path, tag-based invalidation)
- Request coalescing to prevent thundering herd on cache misses
- Compression & modern protocols (Brotli, HTTP/2, HTTP/3/QUIC)
Reliability & optimization:
- Failover to alternate origins and stale-while-revalidate on failures
- Rate limiting & DDoS protection at the edge
- Edge compute (lightweight logic) for auth, redirects, A/B testing
- Monitoring cache hit ratio, latency, and origin load
This design enables the CDN to scale to millions of concurrent users while keeping performance high and origin costs low.
8. How would you scale a search engine for rapid responses?
A scalable search engine must deliver low-latency queries while handling high read traffic and frequent index updates. The design focuses on efficient indexing, horizontal scaling, and aggressive caching.
Core architecture & data flow:
- Distributed index split into shards (by document ID, term hash, or domain)
- Query routers send requests to relevant shards in parallel
- Search nodes execute queries and return partial results
- Aggregator merges, ranks, and returns the final response
Scalability strategies:
- Sharding & replication: distribute indexes and add replicas to scale reads
- Parallel query execution: query multiple shards concurrently to reduce latency
- Caching: cache popular queries, filters, and top-N results
- Pre-computation: maintain inverted indexes, facets, and relevance signals
Write & update handling:
- Asynchronous indexing pipelines using queues/streams
- Near real-time indexing with periodic refreshes
- Batch updates to reduce index churn
Reliability & performance optimizations:
- Failover to replicas on shard failure
- Circuit breakers & timeouts to avoid slow tail latency
- Monitoring query latency (p95/p99), cache hit rate, and index freshness
This approach keeps search responses fast, reliable, and scalable even with millions of users and large datasets.
9. How would you handle multi-region deployment and failover?
Multi-region deployment ensures high availability, low latency, and disaster recovery by running the system in multiple geographic regions and automatically shifting traffic during failures.
Core design approach:
- Deploy active-active or active-passive regions depending on consistency needs
- Use global DNS or traffic routing to direct users to the nearest healthy region
- Keep services stateless so traffic can shift seamlessly
- Replicate data across regions with defined consistency guarantees
Failover & data strategies:
- Health checks and automatic traffic rerouting on region failure
- Database replication (sync for critical data, async for scale)
- Data partitioning by region where possible to reduce cross-region latency
- Regular backup and restore testing for disaster recovery
Operational considerations:
- Graceful degradation if one region becomes read-only
- Feature flags to disable risky features during incidents
- Observability with region-level metrics and alerts
This design allows the system to survive regional outages while continuing to serve users with minimal disruption.
10. Design a fault-tolerant system with zero single point of failure.
A fault-tolerant system is designed so that no single component failure can bring the system down. This is achieved through redundancy, isolation, and automated recovery at every layer.
Core design principles:
- Redundancy everywhere: multiple instances of each component (app servers, caches, databases)
- Stateless services: enable traffic to shift instantly between instances
- Load balancers deployed in pairs or managed services to avoid SPOF
- Multi-AZ / multi-region deployment to survive zone or regional failures
Data & communication layer:
- Database replication with automatic failover (primary–replica or multi-primary)
- Distributed caches with replication and partitioning
- Message queues/streams with replication to ensure durability
- Idempotent operations to safely retry on failures
Resilience & recovery mechanisms:
- Health checks, heartbeats, and auto-healing (restart/replace failed nodes)
- Circuit breakers, timeouts, and retries with backoff to prevent cascading failures
- Graceful degradation to keep core features available under stress
- Continuous monitoring & alerting to detect issues early
By eliminating single points of failure and automating recovery, the system remains highly available, resilient, and reliable even during component or infrastructure failures.
Advanced & Scenario-Based
1. How would you build a globally replicated database?
A globally replicated database is designed to provide low latency, high availability, and disaster recovery for users across different geographic regions, while carefully managing consistency.
Core design approach:
- Deploy database nodes in multiple regions (active–active or active–passive)
- Choose a replication strategy:
- Synchronous replication for strong consistency (higher latency)
- Asynchronous replication for better scalability and availability
- Partition data geographically so reads and writes stay close to users
Consistency & reliability strategies:
- Use conflict resolution mechanisms (timestamps, version vectors, or last-write-wins)
- Apply leader election or quorum-based writes to maintain correctness
- Support automatic failover and region health checks
- Ensure backup, restore, and data validation across regions
This design balances latency, consistency, and fault tolerance, enabling the database to scale globally while remaining reliable.
2. How to optimize a system for latency (in addition to scalability)?
Optimizing for latency means focusing on how fast each request is served, not just how many requests the system can handle. Even highly scalable systems can feel slow if latency is not carefully controlled.
Key latency-reduction strategies:
- Use CDN and edge caching to deliver static content and cached API responses from locations close to users, reducing round-trip time.
- Add in-memory caching (Redis/Memcached) for frequently accessed data to avoid repeated database calls.
- Reduce network hops by co-locating dependent services and avoiding unnecessary service-to-service calls.
- Execute independent operations in parallel instead of sequentially to shorten critical paths.
- Optimize database queries with proper indexing, query tuning, and smaller payloads to reduce I/O and processing time.
Operational and design best practices:
- Offload non-critical work using asynchronous processing so user-facing requests return quickly.
- Configure timeouts, retries, and circuit breakers to prevent slow dependencies from increasing tail latency.
- Continuously monitor p95 and p99 latency, since tail latency impacts real user experience more than average response time.
Together, these techniques ensure the system remains fast, predictable, and responsive under both normal and peak load conditions.
3. What patterns help scale message queues? (e.g., Kafka partitioning)
Message queues scale by enabling parallel processing, decoupling producers and consumers, and smoothing traffic spikes. The goal is to increase throughput while maintaining reliability and ordering guarantees where needed.
Key scaling patterns:
- Partitioning: split topics into multiple partitions so messages can be processed in parallel by different consumers, increasing throughput.
- Consumer groups: allow multiple consumers to share the load of a topic, with each partition processed by only one consumer in a group.
- Batching: produce and consume messages in batches to reduce network and disk overhead.
- Back-pressure handling: slow down producers or scale consumers when queues start growing to prevent overload.
- Idempotent producers and consumers: safely retry messages without creating duplicates.
- Message retention and replay: store messages for a defined time so consumers can reprocess data in case of failure.
These patterns allow message queue systems to handle very high volumes of events reliably while scaling horizontally with traffic growth.
4. Design event-driven architecture for scalable workflows.
Event-driven architecture (EDA) enables scalable workflows by decoupling services and allowing them to react to events asynchronously, rather than relying on tight, synchronous calls.
Core design approach:
- Services act as event producers, emitting events when state changes occur.
- Events are published to a message broker or event stream.
- Independent event consumers subscribe to relevant events and process them asynchronously.
- Each service owns its data and reacts based on event type, not direct service calls.
Scalability and reliability patterns:
- Use event partitioning (by entity ID, order ID, user ID) to enable parallel processing.
- Ensure at-least-once delivery with idempotent consumers to handle retries safely.
- Apply event versioning and schemas to evolve workflows without breaking consumers.
- Persist events for replay and recovery during failures.
- Prefer event choreography over central orchestration to avoid bottlenecks.
This design allows workflows to scale independently, remain resilient to failures, and handle complex business processes efficiently.
5. How would you scale ML model serving for thousands of requests/second?
Scaling ML model serving requires balancing low latency, high throughput, and efficient resource utilization, while supporting frequent model updates.
Core serving architecture:
- Deploy models behind stateless inference APIs so instances can scale horizontally.
- Use load balancers and auto-scaling to add or remove serving instances based on traffic.
- Separate model training pipelines from the online serving path to avoid interference.
Performance and scalability strategies:
- Use batch inference where latency requirements allow, increasing throughput per instance.
- Apply hardware acceleration (GPUs/TPUs) selectively for compute-heavy models.
- Cache frequent or deterministic predictions to reduce repeated inference.
- Use model sharding or ensemble routing for large models.
Reliability and operations:
- Support model versioning, A/B testing, and canary deployments for safe rollouts.
- Monitor latency, error rate, and resource utilization to trigger scaling decisions.
- Implement timeouts and fallback models to handle failures gracefully.
These techniques ensure ML serving systems remain fast, reliable, and scalable under high request volumes.
6. How would you handle eventual consistency across distributed caches?
In distributed cache systems, eventual consistency is a common trade-off to achieve high availability and low latency. The goal is to minimize stale data while keeping the system fast and scalable.
Key strategies to manage consistency:
- Use TTL-based expiration so cached data is automatically refreshed after a short, controlled time.
- Apply cache invalidation on writes, either by deleting or updating cache entries whenever the source data changes.
- Use event-based or pub/sub mechanisms to notify all cache nodes of updates or invalidations.
- Implement versioned cache keys (e.g., including timestamps or version numbers) to avoid serving outdated values.
Operational considerations:
- Accept slightly stale reads where business logic allows, keeping the database as the source of truth.
- Use write-through or write-behind caching selectively for critical data.
- Provide safe fallback to the database on cache misses or inconsistencies.
These techniques help balance performance, consistency, and scalability in large distributed cache environments.
7. Design an API gateway pattern for efficient service orchestration.
An API Gateway acts as a single entry point for clients and simplifies interactions with multiple backend services, improving scalability, security, and performance.
Core gateway responsibilities:
- Request routing to appropriate backend services
- Service orchestration, aggregating responses from multiple services into a single API
- Authentication and authorization (JWT, OAuth)
- Rate limiting and throttling to protect backend services
- Protocol transformation (HTTP ↔ gRPC, REST ↔ GraphQL)
Scalability and reliability strategies:
- Deploy the gateway as a stateless service behind a load balancer
- Apply caching for common responses to reduce downstream calls
- Use timeouts, retries, and circuit breakers to prevent cascading failures
- Support API versioning and feature flags for safe evolution
Operational considerations:
- Centralized logging, metrics, and tracing for observability
- Fine-grained request validation and transformation
- Horizontal scaling based on traffic patterns
This pattern enables efficient service orchestration while keeping backend services decoupled, resilient, and scalable.
8. What are key trade-offs between synchronous vs asynchronous systems?
Choosing between synchronous and asynchronous communication impacts latency, scalability, reliability, and system complexity. Most large systems use a combination of both.
Synchronous systems:
- Requests wait for an immediate response, making flows easier to understand and debug.
- Provide strong consistency and simpler error handling.
- However, they create tight coupling, increase tail latency, and can fail if any downstream service is slow or unavailable.
Asynchronous systems:
- Requests are decoupled using queues or events, allowing services to process work independently.
- Improve scalability, fault tolerance, and responsiveness, especially under spikes.
- Introduce eventual consistency, more complex debugging, and the need for idempotency and retries.
In practice, synchronous calls are used for user-facing, real-time operations, while asynchronous processing is preferred for background, long-running, or high-volume tasks.
9. How would you scale a financial transaction processing system?
Scaling a financial transaction system requires maintaining strong consistency, correctness, and security while handling high throughput and low latency.
Core design principles:
- Use ACID-compliant databases to ensure transaction integrity
- Apply horizontal partitioning (sharding) by account, customer, or region
- Enforce idempotent transaction processing to avoid duplicates
- Use synchronous validation for critical steps (balance checks, authorization)
Scalability and reliability strategies:
- Separate read and write paths using read replicas for reporting and queries
- Use asynchronous processing for non-critical workflows (notifications, settlements)
- Apply strict ordering per account to avoid race conditions
- Use message queues for durability and retry handling
Operational and security considerations:
- Implement strong authentication, authorization, and auditing
- Monitor latency, failure rates, and fraud signals in real time
- Support multi-region disaster recovery with controlled failover
This approach ensures the system scales safely while preserving financial correctness and regulatory compliance.
10. Describe back-of-envelope estimation for system components during design.
Back-of-the-envelope estimation helps designers quickly approximate system requirements before detailed design, ensuring the architecture can handle expected load.
Estimation steps:
- Traffic estimation: calculate daily active users, peak concurrent users, and requests per second (RPS).
- Data size estimation: estimate data generated per request and total storage growth per day/month/year.
- Read/write ratio: determine how many reads vs writes the system will handle.
- Peak load planning: size systems for 2–5× average traffic to handle spikes.
- Latency targets: define acceptable response times for critical APIs.
Component-level sizing:
- Estimate number of servers needed based on RPS per instance.
- Size databases based on storage, IOPS, and growth rate.
- Estimate cache capacity using working-set size and eviction policy.
- Plan network bandwidth for peak traffic.
These quick calculations guide capacity planning, cost estimation, and architecture choices early in the design process.
Tips for Answering Scalability Questions
✔️ Clarify requirements first: Ask about traffic patterns, data size, SLAs, and failure expectations.
✔️ Draw architecture diagrams: Use boxes and arrows to show components and data flows.
✔️ Discuss trade-offs: E.g., consistency vs availability, simplicity vs performance.
✔️ Use real examples: Reference YouTube, Instagram, Twitter for scalable components.