📊 2026 Career Guide
⚡ 2026 Verified Program Offer: 6 Months 100% Live Training • ₹1,20,000 Flat Fee (₹10,000/mo 0% EMI) • Official IBM & Microsoft Badges • Guaranteed 6-Mo Paid Internship*
📥 Download 2026 Syllabus & Fee PDF →
FREE 2026 PDF DOWNLOAD • VERIFIED LAB CODE

📥 Download Complete 2026 Printable PDF Notes, Architecture Diagrams & GitHub Code

Get instant free access to the 2026 printable PDF cheat-sheet, runnable lab repositories, interview evaluation rubric, and AI Campus 6-Month Paid Corporate Internship roadmap.

Download Free PDF & Syllabus Roadmap →

Top 12 Senior System Design (HLD & Distributed Systems) Technical Interview Questions & Answers (2026)

Enterprise-grade distributed systems architectural questions, trade-offs, and production scenarios asked during System Design and High-Level Design (HLD) rounds at FAANG, Tier-1 MNCs, and AI unicorns:

Q1 Explain the CAP Theorem and how modern distributed databases (e.g. Cassandra vs PostgreSQL/Spanner) make trade-offs.

The CAP Theorem proves that a distributed data store can simultaneously guarantee at most two of three properties: Consistency (every read receives the most recent write or an error), Availability (every request receives a non-error response without guarantee it is the most recent), and Partition Tolerance (system continues to operate despite network packet loss between nodes). Because network partitions are inevitable in physical infrastructure, systems must choose between CP (e.g. MongoDB, Google Cloud Spanner via TrueTime API) which reject writes during partitions to maintain strict serializability, or AP (e.g. Apache Cassandra, DynamoDB) which use eventual consistency, vector clocks, and hinted handoffs to accept writes during network splits.

Q2 How does Consistent Hashing work and why is it preferred over simple modulo hashing (hash(key) % N) in distributed caches?

In simple modulo hashing, adding or removing a cache node changes the denominator N, which remaps virtually all cached keys (specifically (N-1)/N keys), triggering a massive cache avalanche against backend databases. Consistent Hashing maps both server nodes and data keys to positions on a 360-degree virtual circular ring (e.g., using SHA-256). A key is assigned to the first server found moving clockwise. When a node joins or fails, only keys in its immediate segment (an average of K/N keys) must be migrated. Modern systems use Virtual Nodes (vnodes) (e.g., 256 virtual positions per physical server) to prevent hash hotspots and ensure uniform data distribution.

Q3 What is the difference between Database Sharding and Horizontal Partitioning, and how do you handle cross-shard queries?

Horizontal Partitioning splits rows of a single database table across separate tables within the same database engine instance, managed automatically by the RDBMS. Database Sharding is an architectural pattern that distributes partitions across completely separate database servers and physical nodes. Handling cross-shard queries requires either: 1) A centralized routing tier (like Vitess or Citus) that executes parallel Scatter-Gather queries across shards and aggregates results in memory, 2) Data denormalization and secondary indexing in a distributed search index (e.g. Elasticsearch), or 3) Designing the Shard Key around the dominant query access pattern (e.g., sharding by tenant_id or user_id) so 99% of transactions hit a single shard.

Q4 Compare Redis Caching Strategies: Cache-Aside (Lazy Loading) vs Write-Through vs Write-Back (Write-Behind).

Cache-Aside: The application reads from cache first; on a cache miss, it fetches from the database, updates the cache, and returns data. Best for read-heavy workloads with dynamic data, though vulnerable to stale reads if cache invalidation fails. Write-Through: The application writes data to the cache, and the cache synchronously writes to the database before acknowledging success. Guarantees consistency and eliminates stale reads, but incurs write latency. Write-Back: The application writes exclusively to the cache, which asynchronously writes dirty entries to the database in micro-batches. Offers ultra-fast write performance but carries risk of data loss if the cache node crashes before flushing.

Q5 How does Apache Kafka achieve horizontal scalability and high throughput, and how do Consumer Groups manage partitions?

Kafka achieves gigabyte-per-second throughput via four core architectural optimizations: 1) Sequential Disk I/O via an immutable append-only commit log, 2) Zero-Copy Transfer using Linux sendfile() syscall to stream data from OS page cache directly to network sockets without user-space buffer copies, 3) Batching & Compression (Snappy, zstd) across network packets, and 4) Partitioning. A Kafka topic is split into independent partitions distributed across cluster brokers. Within a Consumer Group, each partition is consumed exclusively by a single consumer instance, allowing parallel linear consumption up to the partition count.

Q6 Design a Distributed Rate Limiter: Compare Token Bucket vs Leaky Bucket vs Sliding Window Counter algorithms in Redis.

Token Bucket: Tokens are replenished into a bucket at a fixed rate up to max capacity; each request consumes a token. Allows bursts while enforcing average rate. Leaky Bucket: Requests enter a FIFO queue and leak out at a constant rate; excess requests overflow and drop. Smooths traffic bursts into predictable streams. Sliding Window Counter (Production Standard): Combines fixed-window counters with weights of previous windows. In Redis, implemented via a Redis Sorted Set (ZADD, ZREMRANGEBYSCORE, ZCARD) wrapped inside an atomic Lua script to eliminate race conditions across distributed API gateway instances.

Q7 What is the Circuit Breaker pattern (Resilience4j / Envoy) and how does it prevent cascading failures in Microservices?

In distributed microservices, if Service B becomes slow or unresponsive, upstream Service A's thread pools quickly become exhausted waiting for timeouts, causing Service A to fail and cascading throughout the platform. A Circuit Breaker monitors failure rates. It starts in Closed state (traffic flows normally). When failure or latency rates exceed a threshold (e.g., 50% over a 10s window), it trips into Open state, immediately failing calls or returning fallback data without contacting Service B. After a sleep window (e.g. 30s), it enters Half-Open, allowing a trial percentage of probe requests. If probes succeed, it resets to Closed; otherwise, it returns to Open.

Q8 Compare Layer 4 (Transport) vs Layer 7 (Application) Load Balancing with NGINX, HAProxy, and AWS ALB.

Layer 4 Load Balancing: Operates at the TCP/UDP transport layer. It routes network packets based on IP addresses and ports without inspecting application payload or TLS handshake contents (TCP SYN/ACK proxying). It has ultra-low CPU overhead and high packet throughput. Layer 7 Load Balancing: Operates at the application layer, terminating TLS connections and parsing HTTP headers, cookies, query parameters, and JSON payloads. It enables path-based routing (e.g., /api/v1/payments vs /api/v1/search), SSL/TLS offloading, gRPC multiplexing, sticky sessions, and JWT validation.

Q9 How do you implement Distributed Locks in Redis, and what are the limitations of the Redlock algorithm?

A single-instance Redis distributed lock is acquired using atomic SET resource_name my_random_value NX PX 30000 and released using an atomic Lua script verifying ownership (if redis.call('get',KEYS[1]) == ARGV[1] then return redis.call('del',KEYS[1]) else return 0 end). To handle Redis node failover where asynchronous replication might release a lock prematurely, Salvatore Sanfilippo created Redlock, which acquires locks across N independent masters (e.g., 5 nodes) and requires a quorum (3/5) within a strict time bound. However, as Martin Kleppmann proved, distributed locks without fencing tokens can fail under prolonged GC pauses, VM clock jumps, or asynchronous network unresponsiveness.

Q10 Compare Database Indexing internals: B-Tree / B+ Tree vs LSM-Tree (Log-Structured Merge-Tree).

B+ Tree (PostgreSQL, MySQL InnoDB): Balances a tree of fixed-size disk pages (typically 16KB). All values reside in leaf nodes connected by a doubly-linked list, providing fast O(log N) point lookups and efficient sequential range scans. However, random writes cause in-place updates and page splits, leading to write amplification. LSM-Tree (Cassandra, RocksDB, Bigtable): Optimizes for high-velocity writes by buffering writes in an in-memory sorted MemTable and append-only commit log. When full, it flushes sequentially to disk as immutable SSTables. Reads check MemTable, Bloom filters, and SSTables via a multi-way merge, trading slower reads for near-zero write amplification.

Q11 How does Content Delivery Network (CDN) edge caching work and how do you handle stale cache invalidation globally?

CDNs deploy Anycast DNS routing to terminate client TCP/TLS handshakes at the geographically closest Point of Presence (PoP). Static and semi-dynamic HTTP responses are cached using standard headers: Cache-Control: public, max-age=3600, s-maxage=86400, stale-while-revalidate=60. For immediate invalidation of updated product or course data, CDNs support Cache-Tag (Surrogate-Key) purging. Instead of purging by URL regex, the origin server tags responses with IDs (e.g., Surrogate-Key: course-101 catalog). When a record updates, the backend triggers an instant API purge on that specific surrogate key across all global edge nodes within ~150 milliseconds.

Q12 How do you generate Globally Unique Distributed IDs at Scale without database auto-increment bottlenecks (Twitter Snowflake ID)?

Traditional database auto-increment keys create single-point-of-failure contention and leak business volume metrics. Twitter Snowflake generates 64-bit unique IDs that are roughly time-sortable: 1 bit unused (sign bit), 41 bits timestamp in milliseconds (~69 years lifespan), 10 bits machine/node ID (supporting 1,024 distributed generator instances), and 12 bits sequence number (allowing 4,096 unique IDs per millisecond per worker node). Snowflake generators produce up to 4 million unique, k-sorted, 64-bit integer IDs per second without network coordination, perfectly suited for B-Tree index clustering.

Q1 Explain the 4 fundamental pillars of OOPs (Encapsulation, Abstraction, Inheritance, Polymorphism) with production examples.

Encapsulation bundles data and methods while restricting direct access via private fields and public accessors.

Abstraction hides implementation complexity behind interfaces or abstract classes.

Inheritance enables code reuse and hierarchical categorization.

Polymorphism allows objects to take multiple forms through Compile-time method overloading and Runtime method overriding.

JAVA EXAMPLE
// Runtime Polymorphism in Java
interface PaymentGateway {
    boolean processPayment(double amount);
}
class RazorpayGateway implements PaymentGateway {
    public boolean processPayment(double amount) { return true; }
}

Q2 What is the difference between SOLID design principles in Low-Level Design (LLD)?

Single Responsibility: A class should have one reason to change.

Open/Closed: Open for extension, closed for modification.

Liskov Substitution: Subclasses must be substitutable for base classes.

Interface Segregation: Clients shouldn't be forced to depend on unused interfaces.

Dependency Inversion: Depend on abstractions, not concretions.

JAVA EXAMPLE
# Factory Pattern adhering to Open/Closed:
class NotificationFactory {
    static Notification create(type) { /* returns SMS/Email */ }
}

Q3 How do you detect a cycle in a Directed Graph vs an Undirected Graph?

For Undirected Graphs, use BFS/DFS with a visited set and parent tracking, or Disjoint Set Union (DSU).

For Directed Graphs, use DFS with a 3-color state (Unvisited=0, Visiting=1, Visited=2) or Kahn's Algorithm (Topological Sort with in-degrees). If topological sort order doesn't include all vertices, a cycle exists.

PYTHON EXAMPLE
def has_cycle_directed(V, adj):
    in_degree = [0] * V
    for u in range(V):
        for v in adj[u]: in_degree[v] += 1
    q = [i for i in range(V) if in_degree[i] == 0]
    count = 0
    while q:
        node = q.pop(0)
        count += 1
        for neighbor in adj[node]:
            in_degree[neighbor] -= 1
            if in_degree[neighbor] == 0: q.append(neighbor)
    return count != V

Q4 Explain the 0/1 Knapsack Problem and how to optimize space complexity from O(N*W) to O(W).

Standard 2D dynamic programming builds a table dp[i][w] representing max value considering first i items with weight limit w.

Because each state dp[i][w] depends only on the previous row dp[i-1][w] and dp[i-1][w - weight[i]], we can compress the table into a single 1D array by iterating weights backwards from W down to weight[i].

PYTHON EXAMPLE
def knapsack(W, wt, val, n):
    dp = [0] * (W + 1)
    for i in range(n):
        for w in range(W, wt[i] - 1, -1):
            dp[w] = max(dp[w], dp[w - wt[i]] + val[i])
    return dp[W]

Q5 How do you design a distributed URL Shortener (TinyURL) at FAANG scale in System Design (HLD)?

Key requirements: 100M URLs/month, low-latency redirection (<20ms), high availability (99.999%).

Architecture: Base62 encoding on unique 64-bit integer IDs generated by Twitter Snowflake or ZooKeeper range counters. Store in Cassandra/DynamoDB (key-value schema) with Redis caching tier and LRU eviction.

TEXT EXAMPLE
# 64-bit ID -> Base62 string (a-z, A-Z, 0-9) yielding 7-character URLs supporting 3.5 Trillion unique links!

Q6 Explain the CAP Theorem and PACELC Theorem in Distributed Systems.

CAP Theorem states a distributed store can guarantee at most 2 out of Consistency, Availability, and Partition Tolerance.

PACELC extends CAP: If there is a Partition (P), trade off Availability (A) and Consistency (C); Else (E), trade off Latency (L) and Consistency (C). Example: DynamoDB/Cassandra choose PA/EL; Spanner chooses PC/EC.

TEXT EXAMPLE
# Spanner: Strong Consistency + Low Latency via TrueTime GPS clocks

Q7 How does Consistent Hashing prevent cache stampedes in distributed cache clusters?

Consistent hashing maps both servers and cache keys onto a virtual 360-degree hash ring. When a server node is added or removed, only K/N keys need remapping (where K is total keys and N is servers), preventing mass cache invalidation.

TEXT EXAMPLE
# Virtual nodes ensure uniform key distribution across servers.

Q8 Explain LRU Cache implementation with O(1) get() and put() operations.

An LRU cache combines a Doubly Linked List (for O(1) node removal and head-insertion) and a Hash Map (for O(1) key-to-node pointer lookup).

PYTHON EXAMPLE
class Node:
    def __init__(self, k, v): self.k, self.v = k, v; self.prev = self.next = None
# Map stores key -> Node, head is MRU, tail is LRU

Q9 How does Rate Limiting work (Token Bucket vs Leaky Bucket vs Sliding Window Counter)?

Token Bucket allows bursty traffic: tokens accumulate up to capacity; each request consumes a token.

Leaky Bucket processes requests at a strictly constant rate.

Sliding Window Counter in Redis tracks timestamps using Sorted Sets (ZADD, ZREMRANGEBYSCORE, ZCARD) for precise rolling rate limits.

PYTHON EXAMPLE
# Redis sliding window rate limiter:
pipe = redis.pipeline()
pipe.zremrangebyscore(key, 0, now - window)
pipe.zcard(key)
pipe.zadd(key, {now: now})
pipe.expire(key, window)

Q10 What is Database Sharding (Horizontal Partitioning) and how do you handle cross-shard queries?

Sharding splits large tables across separate database instances using a shard key (hash-based or range-based). Cross-shard queries are handled via scatter-gather proxies or by denormalizing common lookup tables across all shards.

TEXT EXAMPLE
# Shard Key Selection: Tenant_ID in multi-tenant SaaS guarantees 99% single-shard routing.
2026 Career Fast-Track

Accelerate Your Career with Guaranteed Paid Internship*

Transparent ₹1,20,000 Fee (Inclusive of GST) • ₹10,000/month No-Cost EMI • 6-Month Corporate Paid Internship (₹15,000 – ₹35,000/mo stipend) with official IBM & Microsoft Credly credentials.