Cracking ML Interviews

Open in the interactive study hub 32 interview questions, also in the practice drill

Backend System Design Interview Guide

This guide adapts the provided standalone HTML system design guide into the repo's existing markdown-driven study flow. It is meant to complement the ML-first design framework with a broader backend interview checklist.


Table of Contents

  1. At a Glance
  2. Top 10 to Memorize First
  3. How to Use This Guide
  4. Reference Backend Architecture
  5. How to Explain Architecture in an Interview
  6. Interview Q&A (Scalability and Databases)
  7. Data Modeling, DDD, and Data-Driven Development
  8. Interview Q&A (Caching, Distribution, and Reliability)
  9. Worked Architecture Examples
  10. Operational Review Checklist
  11. Key Trade-Off Cheat Sheet
  12. Suggested Interview Walkthrough
  13. Common Mistakes in Backend Interviews
  14. References
  15. Recommended Follow-Ups in This Repo

At a Glance


Top 10 to Memorize First

  1. Load balancing
  2. Caching strategies
  3. SQL vs NoSQL
  4. Database sharding
  5. CAP theorem
  6. Consistent hashing
  7. Message queues and Kafka
  8. Horizontal vs vertical scaling
  9. Circuit breaker pattern
  10. REST vs GraphQL vs gRPC

Why these first:


How to Use This Guide

For each concept, focus on five things:

  1. Definition: what the concept is in plain language
  2. Why it matters: why interviewers care
  3. Example: where it appears in real systems
  4. Common prompts: how it shows up in interview questions
  5. Trade-off: when it helps and what it costs

Reference Backend Architecture

Most interview systems can be explained as a variation of this baseline:

Client
  |
  v
DNS / CDN / Edge
  |
  v
Load Balancer / API Gateway
  |
  v
Stateless Application Services
  |                 \
  |                  \--> Cache (Redis / Memcached)
  |
  +--> Primary Database / Search Index / Object Store
  |
  +--> Message Queue / Event Stream
          |
          v
       Async Workers / Consumers
          |
          v
   Secondary Stores / Notifications / Analytics / ML Pipelines

What each layer does

Hot path versus async path

A strong answer usually distinguishes:

Examples:

A simple request lifecycle

For a read-heavy endpoint:

  1. Client sends request
  2. Load balancer routes to an app instance
  3. App checks cache
  4. On cache hit, return immediately
  5. On cache miss, query database
  6. Store result in cache
  7. Return response

For a write-heavy endpoint:

  1. Client sends mutation request
  2. App validates auth and business rules
  3. App writes durable state to source-of-truth store
  4. App emits event to queue or stream
  5. Background workers update search, notifications, analytics, or downstream materialized views

How to Explain Architecture in an Interview

Interviewers are not looking for a giant diagram first. They want a sequence of defensible decisions.

Good explanation order

  1. Clarify requirements
  2. State system APIs or core entities
  3. Draw the happy path
  4. Choose storage
  5. Add scale controls
  6. Add failure handling
  7. Add observability and operations

Questions you should ask first

What strong answers sound like

Instead of saying:

Say:

Capacity estimation you should be able to do quickly

Even rough math earns points if it is directionally correct.

Examples:

You do not need exact precision. You need enough math to justify architecture choices.


Interview Q&A (Scalability and Databases)

The 32 core concepts are written as interview questions. Each answer covers the definition, why it matters, an example, common prompts, and the trade-off.

1. Scalability

Q1: What is the difference between horizontal and vertical scaling?

Q2: What is load balancing and which strategies are common?

Q3: What is rate limiting and which algorithms implement it?

Q4: What is auto-scaling and what metrics should drive it?


2. Databases

Q5: How do you choose between SQL and NoSQL?

Q6: How does database indexing work and what does it cost?

Q7: What is replication and what trade-offs does it introduce?

Q8: What is sharding and when do you need it?


Data Modeling, DDD, and Data-Driven Development

These topics sit between "database choice" and "service design." Strong candidates do not just pick Postgres or Kafka; they define the domain, model the data correctly, and design feedback loops so the product can improve with evidence.

Data Modeling Fundamentals

Good backend design starts with the right data model.

Core questions:

Example entities for an e-commerce system:

Typical relational model:

users (user_id)
orders (order_id, user_id, status, created_at)
order_items (order_item_id, order_id, product_id, quantity, unit_price)
payments (payment_id, order_id, provider, amount, status)
shipments (shipment_id, order_id, carrier, status, tracking_number)

Why this matters:

Normalized versus Read-Optimized Models

Operational systems usually begin with normalized data because:

Read-heavy systems often add denormalized views because:

A strong answer distinguishes:

This is one reason patterns like CQRS, materialized views, and search indexes appear so often.

Data Modeling Pitfalls to Call Out

Domain-Driven Design (DDD)

DDD is useful when the domain is complex and the hardest problems are not technical primitives but business rules and model boundaries.

Key ideas:

Bounded Contexts

A common backend mistake is to pretend the whole company shares one global model.

Example:

Order status in the ordering context does not need to mean the same thing as payment status in the payments context.

That separation gives you:

Aggregates and Consistency Boundaries

An aggregate defines what must be changed together atomically.

Example:

Strong interview point:

Context Mapping

When domains talk to each other, define the contract clearly.

Common choices:

Example:

This is where DDD and event-driven architecture connect naturally.

Data-Driven Development

Data-driven development means product and engineering decisions are shaped by instrumentation, experiments, and observed behavior rather than intuition alone.

In backend interviews, this usually shows up as:

What to Instrument

At minimum, track:

Example for checkout:

Why this matters:

Event Schema Design

A good event usually includes:

Example:

{
  "event_name": "payment_authorized",
  "event_time": "2026-04-10T10:15:00Z",
  "order_id": "ord_123",
  "payment_id": "pay_456",
  "user_id": "usr_789",
  "provider": "stripe",
  "experiment_variant": "checkout_v2",
  "schema_version": 3
}

Strong interview point:

Metrics and Product Feedback Loops

Data-driven systems usually define:

Example for search:

Example for recommendations:

Data-Driven Development in Practice

A mature backend answer may include:

Example: Checkout Domain with DDD and Data-Driven Design

Ordering Context
  - owns cart, checkout, order lifecycle

Payments Context
  - owns authorization, capture, refund

Fulfillment Context
  - owns shipping and delivery workflow

Shared Data / Events
  - checkout_started
  - payment_authorized
  - order_confirmed
  - shipment_dispatched

How this helps:

Interview Questions These Topics Help With


Interview Q&A (Caching, Distribution, and Reliability)

3. Caching

Q9: What is the cache-aside pattern?

Q10: What are write-through and write-behind caching?

Q11: How do CDN and edge caching work?

Q12: What is consistent hashing and why use it?


4. Distributed Systems

Q13: What is the CAP theorem?

Q14: What is the difference between strong and eventual consistency?

Q15: What is leader election and where is it used?

Q16: What is consensus, and how does Raft achieve it?

Q17: What is two-phase commit (2PC)?

Q18: What is the saga pattern?


5. Messaging and Events

Q19: What are message queues and event streaming, and how do they differ?

Q20: What is event sourcing?

Q21: What is CQRS?


6. Networking and APIs

Q22: How do you choose between REST, GraphQL, and gRPC?

Q23: When do you use WebSockets versus long polling?

Q24: How do DNS and anycast routing work in large systems?


7. Storage

Q25: What is the difference between object, block, and file storage?

Q26: What data partitioning strategies exist and how do you choose one?


8. Reliability and Fault Tolerance

Q27: What is the circuit breaker pattern?

Q28: What is idempotency and why does it matter?

Q29: How should you design health checks, timeouts, and retries?

Q30: What are replication factor and quorum?


9. Search and Real-Time Systems

Q31: How do search indexes work?

Q32: How do you store and query time-series data?


Worked Architecture Examples

These are compact examples of how the concepts in this guide fit together in actual interview answers.

Example 1: URL Shortener

Requirements

High-level design

Client -> LB/API -> Shortener Service -> SQL/NoSQL Store
                               |
                               +-> Cache for hot short codes
                               +-> Async analytics event stream

Key decisions

Trade-offs to discuss

Example 2: Notification System

Requirements

High-level design

Producer Services
    |
    v
Notification API -> Queue / Topic -> Channel Workers -> External Providers
                         |
                         +-> Status Store / Retry DLQ / Audit Log

Key decisions

Failure cases to discuss

Strong interview point:

Example 3: Chat or Real-Time Messaging

Requirements

High-level design

Client <-> WebSocket Gateway <-> Chat Service
                               |      \
                               |       \-> Presence Store (Redis)
                               |
                               +-> Message Store
                               +-> Stream / Queue for fan-out, push, analytics

Key decisions

Trade-offs to discuss

Example 4: Search and Discovery Service

Requirements

High-level design

Writers -> Primary DB -> Change Events -> Indexer -> Search Engine
Clients -> API -> Search Service -> Search Engine

Key decisions

Common follow-up

Interviewers often ask how stale the index can be. Your answer should tie staleness budget to product expectations.


Operational Review Checklist

Before finishing a backend design answer, quickly review these dimensions.

Functional shape

Scale

Reliability

Data correctness

Operations

Security


Key Trade-Off Cheat Sheet

Trade-Off Choose A When... Choose B When...
Consistency vs Availability Bank transfers, inventory, strict correctness Social feeds, shopping carts, graceful degradation matters more
SQL vs NoSQL Complex joins, transactions, strong schema discipline Massive write scale, flexible schema, denormalized access
Sync vs Async User needs immediate result on the hot path Throughput, decoupling, and resilience matter more
Cache-Aside vs Write-Through Read-heavy workloads can tolerate some staleness Writes must keep cache close to source of truth
Monolith vs Microservices Early stage product, small team, simpler deployment Independent scaling, team autonomy, bounded contexts
Strong vs Eventual Consistency Correctness must dominate latency Slightly stale reads are acceptable
Normalization vs Denormalization Write-heavy data with strong integrity constraints Read-heavy systems that benefit from precomputed views

Suggested Interview Walkthrough

When answering a system design problem, move in this order:

  1. Clarify users, traffic, latency, and correctness requirements.
  2. Draw the happy path end to end.
  3. Choose storage and explain read and write patterns.
  4. Add caches, queues, and background workers where they remove pressure from the hot path.
  5. Explain scaling: load balancers, sharding, replication, and auto-scaling.
  6. Explain failure handling: retries, timeouts, circuit breakers, idempotency, and fallback behavior.
  7. Close with observability, cost, and the key trade-offs you deliberately chose.

Common Mistakes in Backend Interviews


References


View or edit this guide on GitHub