Skip to content

Production-ready system design blueprints, architectural patterns, and scalability strategies for senior engineers and solution architects

License

Notifications You must be signed in to change notification settings

Richardmsbr/system-design-architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

System Design & Architecture Patterns

A comprehensive collection of production-ready system design blueprints, architectural patterns, and scalability strategies. Built from real-world experience designing systems that handle millions of requests per second.


Overview

This repository provides battle-tested architectural patterns and system design templates used in production environments at scale. Each design includes capacity estimation, component deep-dives, failure scenarios, and infrastructure-as-code examples.

Target Audience: Senior Engineers, Solution Architects, Technical Leads, and Engineering Managers preparing for system design interviews or designing real systems.


Table of Contents

  1. System Design Interview Templates
  2. Architectural Patterns
  3. Cloud Reference Architectures
  4. Data Engineering
  5. Observability & Reliability
  6. Infrastructure as Code
  7. Performance Engineering

System Design Interview Templates

Production-grade designs for common system design interview questions. Each template follows a structured approach: requirements gathering, capacity estimation, high-level design, deep-dive components, and failure analysis.

System Complexity Key Technologies Status
URL Shortener Entry DynamoDB, Redis, CloudFront Complete
Rate Limiter Entry Redis, Token Bucket, Sliding Window Complete
Distributed Cache Intermediate Consistent Hashing, Redis Cluster Complete
Message Queue Intermediate Kafka, RabbitMQ, SQS Complete
Real-time Messaging Intermediate WebSocket, Cassandra, Signal Protocol Complete
News Feed Intermediate Fan-out, Timeline Service, Graph DB Complete
Search Autocomplete Intermediate Trie, Elasticsearch, Prefix Trees Complete
Video Streaming Advanced Adaptive Bitrate, CDN, Transcoding Complete
Ride Sharing Advanced Geospatial Index, Real-time Matching Complete
Distributed File System Advanced GFS, HDFS, Erasure Coding Complete
Payment System Advanced ACID, Idempotency, Reconciliation Complete
Ad Serving Platform Expert RTB, ML Inference, Sub-10ms Latency Complete

Architectural Patterns

Distributed Systems Patterns

patterns/
β”œβ”€β”€ communication/
β”‚   β”œβ”€β”€ api-gateway.md              # Request routing, auth, rate limiting
β”‚   β”œβ”€β”€ service-mesh.md             # Istio, Linkerd, mTLS
β”‚   β”œβ”€β”€ async-messaging.md          # Event-driven, pub/sub, queues
β”‚   └── grpc-federation.md          # Schema stitching, federation
β”‚
β”œβ”€β”€ data-management/
β”‚   β”œβ”€β”€ cqrs.md                     # Command Query Responsibility Segregation
β”‚   β”œβ”€β”€ event-sourcing.md           # Append-only event log, projections
β”‚   β”œβ”€β”€ saga-pattern.md             # Distributed transaction coordination
β”‚   β”œβ”€β”€ outbox-pattern.md           # Reliable event publishing
β”‚   └── change-data-capture.md      # Debezium, database replication
β”‚
β”œβ”€β”€ resilience/
β”‚   β”œβ”€β”€ circuit-breaker.md          # Failure isolation, fallbacks
β”‚   β”œβ”€β”€ bulkhead.md                 # Resource isolation
β”‚   β”œβ”€β”€ retry-backoff.md            # Exponential backoff, jitter
β”‚   └── timeout-patterns.md         # Cascading failure prevention
β”‚
└── scaling/
    β”œβ”€β”€ horizontal-scaling.md       # Stateless services, auto-scaling
    β”œβ”€β”€ database-sharding.md        # Consistent hashing, range partitioning
    β”œβ”€β”€ read-replicas.md            # Read scaling, replication lag
    └── caching-strategies.md       # Write-through, write-behind, cache-aside

Pattern: CQRS with Event Sourcing

                                    WRITE PATH
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚   Client    │────>β”‚  Command    │────>β”‚   Domain    │────>β”‚   Event     β”‚
    β”‚             β”‚     β”‚   Handler   β”‚     β”‚   Model     β”‚     β”‚    Store    β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                                                                       β”‚
                                                                       v
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                           EVENT BUS (Kafka)                             β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               v                       v                       v
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚   Projection    β”‚     β”‚   Projection    β”‚     β”‚   Projection    β”‚
    β”‚   (List View)   β”‚     β”‚  (Analytics)    β”‚     β”‚   (Search)      β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚                       β”‚                       β”‚
             v                       v                       v
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚   PostgreSQL    β”‚     β”‚   ClickHouse    β”‚     β”‚  Elasticsearch  β”‚
    β”‚   (Read Model)  β”‚     β”‚   (OLAP)        β”‚     β”‚   (Full-text)   β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    ^
                                    β”‚
                                READ PATH
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
    β”‚   Client    │────>β”‚   Query     β”‚β”€β”€β”€β”€β”€β”˜
    β”‚             β”‚     β”‚   Handler   β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Cloud Reference Architectures

AWS Production Architecture: Multi-Region Active-Active

                                 GLOBAL
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                                                                         β”‚
    β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
    β”‚     β”‚  Route 53   β”‚              β”‚  CloudFront β”‚                       β”‚
    β”‚     β”‚  (Latency)  │─────────────>β”‚    (CDN)    β”‚                       β”‚
    β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜                       β”‚
    β”‚                                         β”‚                               β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                               β”‚                               β”‚
              v                               v                               v
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚    US-EAST-1        β”‚       β”‚    EU-WEST-1        β”‚       β”‚    AP-SOUTH-1       β”‚
    β”‚                     β”‚       β”‚                     β”‚       β”‚                     β”‚
    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚       β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚       β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
    β”‚  β”‚      ALB      β”‚  β”‚       β”‚  β”‚      ALB      β”‚  β”‚       β”‚  β”‚      ALB      β”‚  β”‚
    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚       β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚       β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
    β”‚          β”‚          β”‚       β”‚          β”‚          β”‚       β”‚          β”‚          β”‚
    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”  β”‚       β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”  β”‚       β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”  β”‚
    β”‚  β”‚     EKS       β”‚  β”‚       β”‚  β”‚     EKS       β”‚  β”‚       β”‚  β”‚     EKS       β”‚  β”‚
    β”‚  β”‚   Cluster     β”‚  β”‚       β”‚  β”‚   Cluster     β”‚  β”‚       β”‚  β”‚   Cluster     β”‚  β”‚
    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚       β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚       β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
    β”‚          β”‚          β”‚       β”‚          β”‚          β”‚       β”‚          β”‚          β”‚
    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”  β”‚       β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”  β”‚       β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”  β”‚
    β”‚  β”‚    Aurora     β”‚<─┼───────┼─>β”‚    Aurora     β”‚<─┼───────┼─>β”‚    Aurora     β”‚  β”‚
    β”‚  β”‚   Global DB   β”‚  β”‚       β”‚  β”‚   Replica     β”‚  β”‚       β”‚  β”‚   Replica     β”‚  β”‚
    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚       β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚       β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
    β”‚                     β”‚       β”‚                     β”‚       β”‚                     β”‚
    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚       β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚       β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
    β”‚  β”‚ ElastiCache   β”‚  β”‚       β”‚  β”‚ ElastiCache   β”‚  β”‚       β”‚  β”‚ ElastiCache   β”‚  β”‚
    β”‚  β”‚   (Redis)     β”‚  β”‚       β”‚  β”‚   (Redis)     β”‚  β”‚       β”‚  β”‚   (Redis)     β”‚  β”‚
    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚       β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚       β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
    β”‚                     β”‚       β”‚                     β”‚       β”‚                     β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Architecture Catalog

Architecture Use Case Documentation Terraform
3-Tier Web Application Standard web apps Docs Code
Serverless API Event-driven APIs Docs Code
Event-Driven Microservices Decoupled services Docs Code
Data Lake Analytics platform Docs Code
Multi-Region Active-Active Global availability Docs Code
Kubernetes Platform Container orchestration Docs Code
ML Inference Pipeline Real-time predictions Docs Code

Data Engineering

Database Selection Matrix

                            CONSISTENCY
                     Strong ◄─────────────► Eventual

              β”‚
    Write     β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    Heavy     β”‚   β”‚   CockroachDB   β”‚     β”‚    Cassandra    β”‚
              β”‚   β”‚   TiDB, Spanner β”‚     β”‚    ScyllaDB     β”‚
              β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
    T         β”‚
    H         β”‚
    R         β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    O         β”‚   β”‚   PostgreSQL    β”‚     β”‚    MongoDB      β”‚
    U         β”‚   β”‚   MySQL         β”‚     β”‚    DynamoDB     β”‚
    G         β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    H         β”‚
    P         β”‚
    U         β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    T         β”‚   β”‚   SQLite        β”‚     β”‚    Redis        β”‚
              β”‚   β”‚   (Embedded)    β”‚     β”‚    Memcached    β”‚
    Read      β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    Heavy     β”‚
              β”‚

Data Pipeline Architecture

    DATA SOURCES                      INGESTION                   PROCESSING
    ─────────────                    ──────────                   ───────────

    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Application │──┐
    β”‚    Logs     β”‚  β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                     β”‚       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚       β”‚             β”‚       β”‚             β”‚
    β”‚  Database   │──┼──────>β”‚   Kafka     │──────>β”‚   Flink     β”‚
    β”‚    CDC      β”‚  β”‚       β”‚  Connect    β”‚       β”‚   Spark     β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚       β”‚             β”‚       β”‚             β”‚
                     β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚                                    β”‚
    β”‚   API       β”‚β”€β”€β”˜                                    β”‚
    β”‚  Events     β”‚                                       β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                       β”‚
                                                          β”‚
                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                           β”‚                              β”‚                              β”‚
                           v                              v                              v
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚     S3      β”‚              β”‚ ClickHouse  β”‚              β”‚Elasticsearchβ”‚
                    β”‚ (Data Lake) β”‚              β”‚   (OLAP)    β”‚              β”‚  (Search)   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

                                                 CONSUMPTION
                                                 ───────────

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Athena    β”‚              β”‚   Grafana   β”‚              β”‚   Kibana    β”‚
                    β”‚   Presto    β”‚              β”‚   Superset  β”‚              β”‚             β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Observability & Reliability

Metrics That Matter

Category Metric Target Alert Threshold
Latency P50 < 50ms -
Latency P99 < 200ms > 500ms
Latency P99.9 < 1s > 2s
Availability Uptime 99.99% < 99.9%
Error Rate 5xx < 0.1% > 1%
Saturation CPU < 70% > 85%
Saturation Memory < 80% > 90%
Saturation Disk I/O < 70% > 85%

SLO/SLI Framework

    SERVICE LEVEL OBJECTIVES
    ────────────────────────

    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                                                                         β”‚
    β”‚  SLI: Request Latency                                                   β”‚
    β”‚  ───────────────────                                                    β”‚
    β”‚  Definition: Time from request received to response sent                β”‚
    β”‚  Measurement: Histogram at load balancer                                β”‚
    β”‚                                                                         β”‚
    β”‚  SLO: 99% of requests complete in < 200ms                              β”‚
    β”‚  ───                                                                    β”‚
    β”‚  Error Budget: 1% (432 minutes/month)                                   β”‚
    β”‚                                                                         β”‚
    β”‚  Current Status:                                                        β”‚
    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
    β”‚  β”‚β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β”‚ 78%    β”‚
    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
    β”‚  Error Budget Remaining: 95 minutes                                     β”‚
    β”‚                                                                         β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Infrastructure as Code

Terraform Module Structure

terraform/
β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ networking/
β”‚   β”‚   β”œβ”€β”€ vpc/
β”‚   β”‚   β”œβ”€β”€ subnets/
β”‚   β”‚   └── security-groups/
β”‚   β”‚
β”‚   β”œβ”€β”€ compute/
β”‚   β”‚   β”œβ”€β”€ eks/
β”‚   β”‚   β”œβ”€β”€ ecs/
β”‚   β”‚   └── lambda/
β”‚   β”‚
β”‚   β”œβ”€β”€ database/
β”‚   β”‚   β”œβ”€β”€ aurora/
β”‚   β”‚   β”œβ”€β”€ dynamodb/
β”‚   β”‚   └── elasticache/
β”‚   β”‚
β”‚   └── observability/
β”‚       β”œβ”€β”€ cloudwatch/
β”‚       β”œβ”€β”€ prometheus/
β”‚       └── grafana/
β”‚
β”œβ”€β”€ environments/
β”‚   β”œβ”€β”€ dev/
β”‚   β”œβ”€β”€ staging/
β”‚   └── production/
β”‚
└── examples/
    β”œβ”€β”€ 3-tier-webapp/
    β”œβ”€β”€ serverless-api/
    └── data-lake/

Performance Engineering

Latency Reference

Operation Time Notes
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache
Compress 1KB with Snappy 3,000 ns
Send 1KB over 1 Gbps 10,000 ns
Read 4KB randomly from SSD 150,000 ns 150 us
Read 1MB sequentially from memory 250,000 ns 250 us
Round trip within datacenter 500,000 ns 500 us
Read 1MB sequentially from SSD 1,000,000 ns 1 ms
Disk seek 10,000,000 ns 10 ms
Read 1MB sequentially from disk 20,000,000 ns 20 ms
Send packet CA to Netherlands 150,000,000 ns 150 ms

Capacity Estimation Formulas

Daily Active Users (DAU) = MAU * 0.2

Requests per Second = (DAU * avg_requests_per_user) / 86400

Peak RPS = Average RPS * 3 (rule of thumb)

Storage per Year = users * data_per_user * 365 * replication_factor

Bandwidth = RPS * average_response_size

Servers Required = Peak RPS / RPS_per_server * (1 + redundancy_factor)

Cache Size = Working Set * (1 / cache_hit_ratio - 1)

Contributing

Contributions are welcome. Please review the contribution guidelines before submitting.

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with appropriate documentation
  4. Submit a pull request with a clear description

License

MIT License - see LICENSE for details.


Maintained by Richard

About

Production-ready system design blueprints, architectural patterns, and scalability strategies for senior engineers and solution architects

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages