githubEdit

HLD Template

Complete step-by-step approach for High-Level Design interviews Optimized for 45-60 minute interviews at senior/staff engineer level

Interview Flow Timeline

Phase
Time
Activity

1. Requirements

0-10 min

Clarify functional & non-functional requirements

2. Estimation

10-15 min

Back-of-envelope capacity planning

3. API Design

15-20 min

Define external interfaces

4. Data Model

20-25 min

Database schema & storage strategy

5. High-Level Design

25-40 min

Component diagram, data flow

6. Deep Dives

40-55 min

Scale, failures, trade-offs

7. Wrap-up

55-60 min

Summary, Q&A, next steps


Phase 1: Requirements Gathering (0-10 min)

Goals

  • Align on scope with interviewer

  • Identify constraints and scale

  • Clarify assumptions

  • Don't: Jump into design before understanding requirements

Functional Requirements

Template Questions:

Example: URL Shortener

Non-Functional Requirements

Use PASS-R Framework:

Performance

  • Latency targets? (e.g., P99 < 200ms)

  • Throughput? (e.g., 10K QPS)

Availability

  • Uptime SLA? (99.9% = 8.7 hours/year downtime)

  • Acceptable downtime window?

Scalability

  • Expected growth? (10M users today → 100M in 1 year?)

  • Peak vs average load? (3x spike during events?)

Security

  • Authentication needed?

  • Data privacy requirements? (GDPR, PII)

  • Rate limiting? DDoS protection?

Reliability

  • Data durability? (can we lose data?)

  • Consistency requirements? (strong vs eventual)

Example:


Phase 2: Capacity Estimation (10-15 min)

Goals

  • Estimate storage, bandwidth, QPS

  • Demonstrate quantitative thinking

  • Don't: Spend too long on precise calculations

Key Numbers to Remember

Estimation Template

1. Traffic Estimates

2. Storage Estimates

3. Bandwidth Estimates

4. Cache Requirements (80/20 Rule)


Phase 3: API Design (15-20 min)

REST API Template

Naming Conventions:

  • Use nouns (not verbs): /users, not /getUsers

  • Plural for collections: /orders, not /order

  • Hierarchical: /users/123/orders

Example: URL Shortener

Standard Error Responses:


Phase 4: Data Model (20-25 min)

Database Schema

URL Shortener Example:

SQL Schema:

NoSQL Schema (DynamoDB):

Indexing Strategy


Phase 5: High-Level Design (25-40 min)

Component Diagram

URL Shortener Architecture:

Data Flow

Write Flow (Create Short URL):

Read Flow (Redirect):


Phase 6: Deep Dives (40-55 min)

Common Deep Dive Topics

1. Short Code Generation

Base62 Encoding:

Collision Handling:

2. Scaling the Database

Sharding Strategy:

Read Replicas:

3. Caching Strategy

Cache-Aside (Lazy Loading):

Cache Eviction:

  • LRU (Least Recently Used)

  • TTL (Time-To-Live): 24 hours


[Continued with more sections: Failure Scenarios, Monitoring, Security...]

Last updated