Neo System Design
A comprehensive system design reference distilled from 150+ engineering articles covering distributed systems, databases, networking, security, cloud, APIs, microservices, and real-world architectures.
When to Use
- Designing or reviewing system architecture
- Making infrastructure or technology decisions
- Evaluating trade-offs (SQL vs NoSQL, REST vs GraphQL, etc.)
- Implementing caching, load balancing, authentication, or messaging patterns
- Reviewing code for scalability, reliability, or performance concerns
- System design interview preparation or discussion
When NOT to Use
- Pure frontend/UI work with no backend considerations
- Simple CRUD without scale concerns
- Language syntax questions unrelated to architecture
Section 1: Fundamentals
1.1 Byte Ordering (Endianness)
- Little Endian: Least significant byte at lowest address. Used by Intel x86.
- Big Endian: Most significant byte at lowest address. Used in network communications, file storage, older PowerPC/Motorola 68k.
- Critical when transferring data between systems with different endianness.
1.2 How Programming Languages Execute
| Type | Languages | Mechanism |
|---|---|---|
| Compiled | C, C++, Go | Source -> machine code -> CPU executes directly |
| Bytecode | Java, C# | Source -> bytecode -> VM executes; JIT can compile to machine code |
| Interpreted | Python, JS, Ruby | Interpreted at runtime; generally slower |
1.3 8 Programming Paradigms
- Imperative - Sequential state-changing steps (C, C++, Java, Python)
- Declarative - Express logic without control flow details
- Object-Oriented (OOP) - Objects encapsulate data + behavior (Java, C++, Python, Ruby)
- Aspect-Oriented (AOP) - Modularize cross-cutting concerns (AspectJ)
- Functional (FP) - Computation as mathematical functions; immutable data (Haskell, Lisp, Erlang)
- Reactive - Asynchronous data streams + change propagation
- Generic - Type-independent reusable code (templates, generics)
- Concurrent - Multiple tasks simultaneously; threading, parallelism
1.4 Concurrency vs Parallelism
- Concurrency: Dealing with many things at once (program structure). Good for I/O-bound tasks.
- Parallelism: Doing many things at once (execution). Requires multi-core. Good for CPU-bound tasks.
1.5 10 Coding Principles
- Follow code specifications (PEP 8, Google Java Style)
- Document the "why", not the "what"
- Robust exception handling
- Follow SOLID principles
- Design for testability
- Appropriate abstraction levels
- Use design patterns judiciously (don't over-design)
- Reduce global dependencies
- Continuous refactoring
- Security is top priority
1.6 CAP, BASE, SOLID, KISS
- CAP Theorem: Consistency + Availability + Partition Tolerance -- pick 2
- BASE: Basically Available, Soft state, Eventually consistent (NoSQL alternative to ACID)
- SOLID: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
- KISS: Keep It Simple, Stupid
1.7 Semantic Versioning (SemVer)
Format: MAJOR.MINOR.PATCH
- MAJOR: Incompatible API changes
- MINOR: Backward-compatible new features
- PATCH: Backward-compatible bug fixes
- Pre-release:
-alpha,-beta,-rc.1
Section 2: System Design Core Concepts
2.1 System Design Blueprint (15 Pillars)
Requirement Gathering, System Architecture, Data Design, Domain Design, Scalability, Reliability, Availability, Performance, Security, Maintainability, Testing, UX Design, Cost Estimation, Documentation, Migration Plan
2.2 High Availability / Throughput / Scalability
| Concern | Metric | Patterns |
|---|---|---|
| High Availability | 99.99% = 8.64s downtime/day | Hot-hot, Hot-warm, Single-leader cluster, Leaderless cluster |
| High Throughput | QPS / TPS | Caching, threading, async processing |
| High Scalability | Horizontal (more servers) / Vertical (more resources) | Watch response time as load increases |
2.3 10 Key System Design Trade-offs
- Vertical vs Horizontal Scaling
- SQL vs NoSQL
- Batch vs Stream Processing
- Normalization vs Denormalization
- Consistency vs Availability
- Strong vs Eventual Consistency
- REST vs GraphQL
- Stateful vs Stateless
- Read-Through vs Write-Through Cache
- Synchronous vs Asynchronous Processing
2.4 Fault-Tolerant System Design (6 Principles)
Replication, Redundancy, Load Balancing, Failover Mechanisms, Graceful Degradation, Monitoring & Alerting
2.5 8 Common System Design Problems & Solutions
Covers standard interview-ready problems: URL shortener, rate limiter, notification system, chat system, news feed, search autocomplete, distributed file storage, video streaming.
2.6 Latency Numbers Every Developer Should Know
| Operation | Latency |
|---|---|
| L1 cache reference | ~1 ns |
| L2 cache reference | ~4-10 ns |
| RAM access (Redis reads) | ~100 ns |
| 1KB over 1 Gbps network | ~10 us |
| NVMe SSD random 4K read | ~20 us |
| Legacy SATA SSD random read | ~100 us |
| DB insert (PostgreSQL) | ~1 ms |
| Same-datacenter round-trip | ~0.5 ms |
| CA -> Netherlands -> CA round-trip | ~150 ms |
| Retry/refresh interval | 1-10 s |
These are the canonical Jeff Dean / Peter Norvig approximations — still useful for back-of-envelope math, but recalibrate for modern hardware: DDR5 memory bandwidth ~48 GB/s, NVMe sequential reads reach 7-15 GB/s, and datacenter networks (25-400 Gbps) now often beat local disk. Rule of thumb: memory > NVMe > network > SATA SSD > HDD, but network can outrun disk on high-tier links.
Section 3: Networking & Protocols
3.1 OSI Model & Data Transmission
Encapsulation: Application (HTTP header) -> Transport (TCP/UDP header) -> Network (IP header) -> Data Link (MAC header) -> Physical (binary bits). De-encapsulation reverses at receiver.
3.2 HTTP Methods
| Method | Idempotent | Purpose |
|---|---|---|
| GET | Yes | Retrieve resource |
| PUT | Yes | Update/create full resource |
| POST | No | Create new resource |
| DELETE | Yes | Delete resource |
| PATCH | No | Partial modification |
| HEAD | Yes | Like GET without body |
| OPTIONS | - | Describe communication options |
| CONNECT | - | Establish tunnel |
| TRACE | - | Loop-back test |
3.3 HTTP/2 vs HTTP/1 vs HTTP/3
HTTP/2 improvements over HTTP/1:
- Binary Framing Layer - Encode to binary frames (not text)
- Multiplexing - Interleave multiple streams over single connection
- Stream Prioritization - Weight-based priority
- Server Push - Proactively send resources (deprecated; Chrome removed support in 2022 — use
103 Early Hints/preloadinstead) - HPACK Header Compression - Reduce overhead
HTTP/3 + QUIC
- Runs over QUIC (UDP), not TCP (RFC 9000/9114). QUIC implements streams, reliability, ordering, and congestion control itself.
- Fixes TCP head-of-line blocking: HTTP/2 multiplexes over one TCP connection, so a single lost packet stalls all streams. QUIC streams are independent — a lost packet only stalls its own stream. Big win on lossy/mobile networks (~10-20% TTFB improvement); marginal on clean wired links.
- Faster connection setup: TLS 1.3 is baked into the QUIC handshake (1-RTT, or 0-RTT on resumption). Connection migration via Connection IDs survives IP changes (Wi-Fi ↔ cellular).
- Discovery via
Alt-Svc: h3=":443": first request uses HTTP/2 over TCP, then upgrades. Falls back gracefully to HTTP/2 if UDP:443 is blocked by middleboxes. - Adoption (mid-2026): ~30-35% of web traffic; supported by all major browsers (Chrome 87+, Firefox 88+, Safari 14+), Cloudflare/Fastly/CloudFront, and Nginx 1.25+ / Caddy.
3.4 HTTP Cookies
- HTTP is stateless; cookies provide session management
- Stored client-side, sent with each request
- Key attributes:
SameSite,Name,Value,Secure,Domain,HttpOnly - Browsers enforce same-origin policy
3.5 REST API Design
Cheatsheet Principles
- Use nouns for endpoints, HTTP verbs for actions
- Version your API (
/v1/) - Support pagination, filtering, sorting
- Use proper status codes
- HATEOAS for discoverability
8 Tips for Efficient API Design
Versioning, Naming conventions, Security, Idempotency, Pagination, Error handling, Async operations, Rate limiting
3.6 REST API vs GraphQL
| Aspect | REST | GraphQL |
|---|---|---|
| Endpoints | Multiple | Single |
| Data fetching | Server decides payload | Client specifies exact fields |
| Caching | Straightforward (HTTP caching) | Complex (custom strategies) |
| Over/Under-fetching | Common problem | Solved by design |
| Best for | Simple, consistent contracts | Complex, evolving frontend needs |
3.7 gRPC
- High-performance RPC framework by Google
- Uses HTTP/2 transport + Protocol Buffers as IDL
- 5X faster than JSON due to binary encoding
- Supports bi-directional streaming, multi-language
- Flow: REST call -> gRPC client -> binary encode -> HTTP/2 -> gRPC server -> decode -> invoke
3.8 GraphQL
- Query language for APIs; developed by Meta (2012), released 2015
- Clients request exactly needed data; single query across multiple sources
- Operations: Queries, Mutations, Subscriptions
- Strong type system; great for microservices
- Downsides: Increased complexity, caching difficulty
4 GraphQL Adoption Patterns
- GraphQL wrapping REST
- GraphQL alongside REST
- GraphQL as BFF (Backend for Frontend)
- GraphQL Federation (multiple subgraphs)
3.9 Polling vs Webhooks
- Polling: Client checks server at intervals; resource-intensive; developer controls timing
- Webhooks: Server pushes events; real-time; efficient; needs retry/failure handling
- Use polling when infra limits prevent webhooks; use webhooks for instant delivery
3.10 UDP Top Use Cases
- Live Video Streaming - Tolerates packet loss, low latency
- DNS - Fast, lightweight (TCP for large responses/zone transfers)
- Market Data Multicast - Efficient multi-recipient delivery
- IoT - Small packets between devices
3.11 IPv4 vs IPv6
- IPv4: 32-bit, ~4.3 billion addresses, NAT required
- IPv6: 128-bit, virtually unlimited addresses, built-in IPsec, no NAT needed
3.12 VPN
4 Steps: Establish secure tunnel -> Encrypt data -> Mask IP address -> Route through VPN server
- Pros: Privacy, anonymity, encryption, IP masking
- Cons: Possible blocking, slower connections, trust in provider
3.13 SSH Protocol (3 Layers)
- Transport Layer - Encryption + integrity
- Authentication Layer - Client identity verification
- Connection Layer - Multiplexes into logical channels
3.14 Top 8 Network Protocols
TCP, UDP, HTTP/HTTPS, FTP, SMTP, DNS, DHCP, WebSocket
3.15 HTTPS / TLS Handshake
("SSL" is the legacy name; SSL and TLS 1.0/1.1 are deprecated. TLS 1.3 (RFC 8446) is the current standard, required for U.S. federal systems since 2024 (NIST SP 800-52r2).)
TLS 1.3 handshake (1-RTT): ClientHello (+ key_share guess) -> ServerHello (+ key_share) + {Certificate + CertificateVerify + Finished, all encrypted} -> Client Finished + application data. Half the round trips of TLS 1.2's 2-RTT handshake.
- 0-RTT resumption: returning clients send app data in the first packet via a pre-shared key — fastest, but replay-vulnerable, so use only for idempotent/safe requests.
- Forward secrecy is mandatory (ECDHE only; static RSA removed).
- AEAD ciphers only — TLS 1.3 keeps 5 cipher suites vs ~300 in TLS 1.2; compression, renegotiation, and MAC-then-encrypt removed (killed CRIME/downgrade attacks).
- Certificate is encrypted (sent after ServerHello), hiding which site you visit; Encrypted Client Hello (ECH) extends this to SNI.
Section 4: Databases
4.1 ACID Properties
- Atomicity: All operations succeed or all fail (rollback)
- Consistency: Database invariants preserved before and after transaction
- Isolation: Concurrent transactions don't interfere; strictest = serializability
- Durability: Committed data persists through failures; distributed systems use replication
4.2 Top 6 Database Models
- Flat Model - Single table, spreadsheet-like
- Hierarchical - Tree structure, parent-child
- Relational - Tables with keys, SQL, normalization (E.F. Codd, 1970)
- Star Schema - Central fact table + dimension tables (OLAP)
- Snowflake - Normalized star schema dimensions
- Network Model - Graph structure, multiple parents/children
4.3 SQL Components
- DDL: CREATE, ALTER, DROP
- DQL: SELECT
- DML: INSERT, UPDATE, DELETE
- DCL: GRANT, REVOKE
- TCL: COMMIT, ROLLBACK
4.4 SQL Query Execution Order
Parsing -> Validity check -> Transform to relational algebra -> Optimize with index info -> Execute plan -> Return results
4.5 Database Locks (9 Types)
Shared (S), Exclusive (X), Update (U), Schema, Bulk Update (BU), Key-Range, Row-Level, Page-Level, Table-Level
4.6 7 Database Scaling Strategies
- Indexing - Speed up reads
- Materialized Views - Pre-computed query results
- Denormalization - Reduce joins at cost of redundancy
- Vertical Scaling - Bigger hardware
- Caching - Reduce DB load
- Replication - Scale reads (primary-replica)
- Sharding - Scale writes + reads (partition data)
4.7 Data Sharding Algorithms
- Range-Based - Partition by value ranges (alphabetical, date)
- Hash-Based - Hash function on shard key; even distribution
- Consistent Hashing - Minimizes data relocation on shard changes
- Virtual Bucket - Two-level mapping: data -> virtual buckets -> physical shards
Shard Key Selection Criteria
Consider: Cardinality, Frequency, Monotonic change
Request Routing
Shard-aware node, Routing tier, Shard-aware client
4.8 8 Key Data Structures Powering Databases
| Structure | Used In | Purpose |
|---|---|---|
| Skiplist | Redis | Sorted sets |
| Hash Index | In-memory DBs | O(1) lookup |
| SSTable | Cassandra, RocksDB | Immutable on-disk sorted storage |
| LSM Tree | Cassandra, LevelDB | High write throughput |
| B-tree | PostgreSQL, MySQL | Balanced read/write |
| Inverted Index | Elasticsearch, Lucene | Full-text search |
| Suffix Tree | Bioinformatics | String pattern matching |
| R-tree | PostGIS | Multi-dimensional/spatial queries |
4.9 Deadlocks
Coffman Conditions (all 4 required): Mutual Exclusion, Hold and Wait, No Preemption, Circular Wait
Prevention: Resource ordering, Timeouts, Banker's Algorithm Recovery: Victim selection (utilization/priority/cost), Rollback + restart
4.10 API Pagination Techniques
- Offset-based -
?offset=20&limit=10(simple but slow at scale) - Cursor-based -
?cursor=abc123(efficient, no skipping) - Page-based -
?page=3&size=10 - Keyset-based -
?after_id=100(fast with indexed columns) - Time-based -
?since=2024-01-01 - Hybrid - Combine approaches
4.11 PostgreSQL Ecosystem
Extensions: TimeSeries (TimescaleDB), Vector/AI (pgvector + pgvectorscale, PostgresML), OLAP (Hydra, Citus), GeoSpatial (PostGIS), Search (pgroonga, ParadeDB/pg_search), Federated (MongoDB/MySQL/Redis connectors via FDW), Graph (Apache AGE)
Note: EdgeDB rebranded to Gel (2025) and repositions itself as a compiler layer on top of Postgres rather than a graph DB. pgvector (with HNSW + IVFFlat indexes) has become the default way to add vector search to Postgres, undercutting most standalone vector-DB startups for small-to-mid workloads.
Section 5: Caching
5.1 Where Data Is Cached (8 Layers)
- Client apps - Browser cache with HTTP expiry headers
- CDN - Static resources at edge locations
- Load Balancer - Frequently requested responses
- Messaging infra - Kafka retention policy
- Services - CPU cache -> memory -> disk
- Distributed Cache - Redis key-value store
- Full-text Search - Elasticsearch indices
- Database - WAL, Buffer pool, Materialized views, Transaction log, Replication log
5.2 Cache Failure Patterns & Solutions
| Pattern | Cause | Solution |
|---|---|---|
| Thunder Herd | Mass key expiry at same time | Randomize TTLs; protect DB with core-only access |
| Cache Penetration | Key doesn't exist in cache OR DB | Cache null values; Bloom filter pre-check |
| Cache Breakdown | Hot key expires | Never expire hot keys (80/20 rule) |
| Cache Crash | Cache completely down | Circuit breaker; cache cluster for HA |
5.3 Top 8 Cache Eviction Strategies
LRU (Least Recently Used), MRU (Most Recently Used), SLRU (Segmented: probationary + protected), LFU (Least Frequently Used), FIFO, TTL-based, Two-Tiered Caching, Random Replacement (RR)
5.4 Data Management Patterns
- Cache Aside - Check cache; on miss, fetch DB, update cache
- Materialized View - Pre-computed query results on disk
- CQRS - Separate read/write models
- Event Sourcing - Store all state changes as event sequence
- Index Table - Secondary indexes for query optimization
- Sharding - Partition data across servers
5.5 Netflix Caching (4 Ways)
EVCache for distributed caching, CDN caching via Open Connect, application-level caching, database query caching
Section 6: Load Balancing
6.1 Top 6 Load Balancing Algorithms
Static:
- Round Robin - Sequential; services must be stateless
- Sticky Round-Robin - Same user -> same server
- Weighted Round-Robin - Admin assigns weights
- Hash - Hash function on IP/URL
Dynamic:
- Least Connections - Fewest active connections
- Least Response Time - Fastest response
6.2 6 Load Balancer Use Cases
Traffic Distribution, High Availability, SSL Termination, Session Persistence (sticky sessions), Horizontal Scalability, Health Monitoring
6.3 Reverse Proxy vs API Gateway vs Load Balancer
- Reverse Proxy: Hides backend servers, shields from attacks (stealth)
- API Gateway: Routes to correct services, handles auth/rate-limiting (organized comms)
- Load Balancer: Distributes traffic evenly (traffic control)
Section 7: Security
7.1 Authentication Methods
Session, Cookie, JWT, Token, SSO, OAuth 2.0
| Method | Mechanism |
|---|---|
| Session | Server stores identity; sends session ID cookie |
| Token | Identity encoded in token sent to browser |
| JWT | Standardized token with digital signature |
| SSO | Central auth service for multiple sites |
| OAuth 2.0 / 2.1 | Limited data access between sites without password sharing |
| Passkeys (WebAuthn/FIDO2) | Passwordless, phishing-resistant public-key credentials syncable across devices; now mainstream (Apple/Google/Microsoft) |
| QR Code | Random token encoded in QR for mobile login |
Session-based vs JWT Authentication
- Session: Server stores session -> sends session ID cookie -> validates each request (stateful)
- JWT: Server issues signed JWT -> no server storage -> verifies with key (stateless)
OAuth 2.0 / 2.1 Flows
Authorization Code (+ PKCE, now required for all clients under OAuth 2.1), Client Credentials, Device Authorization (TVs/CLIs). Deprecated — do not use: Implicit flow and Resource Owner Password Grant (both omitted from the OAuth 2.1 draft). OAuth 2.1 (IETF draft, consolidating RFC 6749 + PKCE + Security BCP RFC 9700) mandates PKCE and exact redirect-URI matching.
REST API Auth Methods
- Basic Auth - Username/password per request (least secure)
- Token Auth - JWT tokens, no credentials per request
- OAuth - Third-party access delegation
- API Key - Unique keys in headers/params (simple but less secure)
7.2 HTTPS / TLS Handshake
Handshake mechanics: see §3.15. Security takeaway: enforce TLS 1.3, disable SSL and TLS 1.0/1.1, require forward secrecy.
7.3 Encoding vs Encryption vs Tokenization
| Purpose | Reversible? | Key needed? | |
|---|---|---|---|
| Encoding | Format conversion (Base64, URL) | Yes | No |
| Encryption | Data confidentiality | Yes | Yes (symmetric/asymmetric) |
| Tokenization | Replace with non-sensitive token | Via vault only | N/A |
7.4 Password Storage
- NEVER store plain text or unsalted hashes
- Use a slow, memory-hard password hash — never fast hashes (SHA-256/MD5):
- Argon2id (default, OWASP-recommended): min m=19 MiB, t=2, p=1 (tune to ~150-250ms/hash)
- scrypt if Argon2 unavailable (N=2^17, r=8, p=1)
- bcrypt only for legacy systems (work factor ≥10; 72-byte input limit)
- PBKDF2-HMAC-SHA256 (≥600,000 iterations) when FIPS-140 compliance is required
- Salt: Unique random string per password (modern algos embed the salt in the output hash string)
- Optionally add a pepper (secret stored separately, e.g. in an HSM/KMS) for defense in depth
- Validate: recompute hash from input + stored params/salt -> constant-time compare
7.5 XSS (Cross-Site Scripting)
- Reflective XSS: Injected script executes immediately (URL-based)
- Stored XSS: Script persists in database; long-term threat
- Mitigation: Input validation, output encoding, Content Security Policy (CSP)
7.6 Cloud Security Cheat Sheet
Covers: IAM, Network security (VPC, firewalls), Encryption (at rest, in transit), Logging & monitoring, Compliance frameworks
7.7 Sensitive Data Management
- Types: PII, health info, IP, financial, education, legal records
- Encryption & Key Management: TLS for transmission; split keys among roles
- Data Desensitization: Anonymization/sanitization
- RBAC: Role-Based Access Control for minimal permissions
- Lifecycle: Grant dev permissions during development; revoke after data goes online
7.8 Top 6 Firewall Use Cases
- Port-Based Rules (80/443 for web)
- IP Address Filtering (whitelist/blacklist)
- Protocol-Based Rules (TCP/UDP/ICMP)
- Time-Based Rules (business hours vs after-hours)
- Stateful Inspection (monitor active connections)
- Application-Based Rules (app-level control)
7.9 DevSecOps
Integrates security into every phase of the development lifecycle: Plan -> Code -> Build -> Test -> Release -> Deploy -> Operate -> Monitor (with security checks at each stage)
Section 8: Microservices & Distributed Systems
8.1 9 Microservices Best Practices
- Separate data storage per microservice
- Keep code at similar maturity level
- Separate build per microservice
- Single responsibility per service
- Deploy into containers
- Design stateless services
- Adopt domain-driven design
- Design micro frontend
- Orchestrate microservices
8.2 9 Essential Components of Production Microservice
API Gateway, Service Registry/Discovery, Load Balancer, Circuit Breaker, Config Management, Logging & Monitoring, Distributed Tracing, Message Queue, Container Orchestration
8.3 Event Sourcing
- Paradigm shift: persist events instead of states
- Event store is the source of truth
- New York Times: Every article since 1851 as events -> denormalized to ElasticSearch
- CDC: Table changes -> events -> Kafka -> consumers
- Microservices: Shopping cart events -> Kafka broker -> fraud/billing/email services
8.4 Change Data Capture (CDC)
5 Steps: Data Modification -> Change Capture (via transaction logs) -> Change Processing -> Change Propagation (message queue) -> Real-Time Integration
Popular stack: Debezium + Kafka Connect + Kafka
8.5 Heartbeat Detection (6 Mechanisms)
Push-Based, Pull-Based, Health Check (CPU/memory metrics), Timestamps, Acknowledgement, Quorum-Based (Paxos/Raft consensus)
8.6 6 Cloud Messaging Patterns
- Async Request-Reply - HTTP 202 + polling for long-running ops
- Publisher-Subscriber - Decouple senders/consumers
- Claim Check - Store payload in DB, transmit reference only
- Priority Queue - Higher priority processed first
- Saga - Data consistency across microservices without distributed transactions
- Competing Consumers - Multiple consumers, same channel (no ordering guarantee)
8.7 Idempotency (6 Use Cases)
RESTful API Requests, Payment Processing, Order Management, Database Operations, User Account Management, Distributed Systems Messaging
8.8 Retry Strategies
- Linear Backoff - Fixed increasing intervals (simple, can cause retry storms)
- Linear Jitter Backoff - Linear + random jitter (reduces synchronized retries)
- Exponential Backoff - 1s, 2s, 4s, 8s... (significantly reduces system load)
- Exponential Jitter Backoff - Exponential + random jitter (best for high-load)
8.9 12-Factor App
- Codebase - One repo, version controlled
- Dependencies - Explicitly declared
- Config - Separate from code (env vars)
- Backing Services - Treat as attached resources
- Build, Release, Run - Strict separation
- Processes - Stateless, share-nothing
- Port Binding - Self-contained via port
- Concurrency - Scale via process model
- Disposability - Fast startup, graceful shutdown
- Dev/Prod Parity - Keep environments similar
- Logs - Treat as event streams
- Admin Processes - Run as one-off processes
Section 9: Messaging & Streaming
9.1 Apache Kafka
KRaft, not ZooKeeper: Kafka now manages its own metadata via the Raft-based KRaft mode (GA in 3.3). Kafka 4.0 (2025) removed ZooKeeper entirely — new clusters are KRaft-only, simplifying ops (one system, faster failover, millions of partitions). Migrate legacy ZooKeeper clusters via the 3.9 bridge release.
Why Kafka Is Fast
- Sequential I/O - Writes sequentially to disk (not random access)
- Zero Copy - OS cache -> network card directly via
sendfile(), skipping application buffer- Without zero-copy: disk -> OS cache -> app -> socket buffer -> NIC (4 copies)
- With zero-copy: disk -> OS cache -> NIC (2 copies)
Can Kafka Lose Messages?
- Producer: Need proper
acksconfig andretries - Broker: Async disk flush risks; configure replicas properly
- Consumer: Auto-commit can ack before processing; use sync + async commits
Top 5 Kafka Use Cases
Log aggregation, Stream processing, Event sourcing, Metrics collection, Activity tracking
9.2 Push Notification Architecture
Channels: In-app, Email, SMS/OTP, Social media Flow: Business services -> Notification gateway (single/batch) -> Distribution service (validate, format, schedule) -> Routers (message queues) -> Channel services -> Delivery tracking & analytics
Key Repositories: Notification template repo, Channel preference repo
9.3 Firebase Cloud Messaging (FCM)
Client sends credentials -> FCM generates registration token -> Client sends token to app server -> Messages composed -> FCM queues if offline -> Platform transport -> Device
Section 10: Cloud & DevOps
10.1 Cloud Disaster Recovery Strategies
| Strategy | RTO | RPO |
|---|---|---|
| Backup & Restore | Hours to days | Hours to last backup |
| Pilot Light | Minutes to hours | Depends on sync frequency |
| Warm Standby | Minutes to hours | Minutes to hours |
| Hot Site / Multi-Site | Near-immediate (minutes) | Seconds |
RTO = Max acceptable downtime. RPO = Max acceptable data loss.
10.2 Docker Architecture
3 Components: Docker Client, Docker Host (daemon), Docker Registry
docker run flow: Pull image -> Create container -> Allocate read-write filesystem -> Create network interface -> Start container
Top 8 Docker Concepts
Images, Containers, Dockerfile, Volumes, Networks, Compose, Registry, Build context
10.3 Kubernetes Architecture
Control Plane: API Server, Scheduler, Controller Manager, etcd (key-value store) Nodes: Pods (smallest unit), Kubelet (agent per node), Kube Proxy (network routing)
Top 10 K8s Design Patterns
Sidecar, Ambassador, Adapter, Leader Election, Work Queue, Scatter/Gather, Init Container, Self-Awareness, Daemon Service, Stateful Service
10.4 Kubernetes Tools Stack
Covers: Package management (Helm), Service mesh (Istio, Linkerd), Monitoring (Prometheus, Grafana), Logging (EFK stack), CI/CD (Argo CD, Flux)
10.5 CI/CD Pipeline
10 Steps: Product owner -> User stories -> Sprint -> Code commit -> Build + unit tests + SonarQube -> Artifact storage + dev deploy -> QA environments -> Regression/performance testing -> UAT -> Production release + SRE monitoring
10.6 GitOps Workflow
- Version Control & Collaboration (Git as hub)
- Declarative System (desired state)
- Automated Delivery (Git-triggered CI/CD)
- Immutable Infrastructure (changes only via Git)
- Observability & Feedback (real-time monitoring)
- Security & Compliance (RBAC)
10.7 Cloud Cost Reduction (6 Techniques)
Reduce Usage -> Terminate Idle Resources -> Right Sizing -> Shutdown During Off-Peak -> Reserve Instances / Savings Plans -> Optimize Data Transfers (compression, CDN)
10.8 Infrastructure as Code (IaC)
- Traditional: Manual setup, step-by-step commands
- IaC: Automates provisioning through code; declarative; source controlled
- Tools: Terraform, OpenTofu (Linux Foundation fork of Terraform after HashiCorp's 2023 switch to the BSL/BUSL source-available license; MPL, community-governed, Terraform-compatible), Pulumi, AWS CloudFormation, Chef, Puppet, Ansible
10.9 Cloud Monitoring (9 Aspects)
Data Collection, Data Storage, Data Analysis, Alerting, Visualization, Reporting & Compliance, Automation, Integration, Feedback Loops
10.10 Linux
File System (FHS)
Root / tree structure. Key directories: /bin, /etc, /home, /var, /usr, /tmp, /dev, /proc
Boot Process (8 Steps)
Power on -> BIOS/UEFI + POST -> Device detection -> Boot device selection -> GRUB -> Kernel + systemd -> default.target + startup scripts -> Login
File Permissions
Owner/Group/Others x Read/Write/Execute. chmod, chown, chgrp.
18 Essential Commands
ls, cd, cp, mv, rm, mkdir, cat, grep, find, chmod, chown, ps, top, kill, df, du, tar, ssh
Section 11: API Design & Testing
11.1 API vs SDK
- API: Rules/protocols for inter-service communication (endpoints, requests, responses)
- SDK: Comprehensive package (tools, libraries, docs) for building on a specific platform; higher-level abstractions
11.2 9 Types of API Testing
- Smoke - Basic post-development validation
- Functional - Compare against requirements
- Integration - End-to-end, inter-service
- Regression - New changes don't break existing
- Load - Simulate various loads, calculate capacity
- Stress - Extreme high loads
- Security - External threat testing
- UI - Data display validation
- Fuzz - Invalid/unexpected input injection
11.3 API Gateway 101
Functions: Request routing, Composition, Protocol translation, Authentication, Rate limiting, Caching, Monitoring, Load balancing
11.4 API Design Cheat Sheet
- Use HTTP methods correctly
- Meaningful resource naming
- Proper status codes (2xx success, 4xx client error, 5xx server error)
- Versioning strategy
- Pagination for list endpoints
- Consistent error response format
Section 12: Git & Version Control
12.1 4 Storage Locations
Working Directory -> Staging Area -> Local Repository -> Remote Repository Most Git commands move files between these locations.
12.2 Git Merge vs Rebase vs Squash
- Merge: Creates merge commit; non-destructive; preserves both histories
- Rebase: Moves commits to head of main; linear history; creates new commits
- Squash: Combines multiple commits into one
- Golden Rule: Never rebase public branches
Section 13: Architecture Patterns
13.1 Top 5 Software Architectural Patterns
Monolithic, Microservices, Event-Driven, Layered (N-tier), Service-Oriented (SOA)
13.2 Top 9 Architectural Patterns for Data & Communication
Request-Response, Event-Driven, Publish-Subscribe, Peer-to-Peer, Client-Server, Master-Slave, Pipe-Filter, Broker, Space-Based
13.3 MVC, MVP, MVVM, MVVM-C, VIPER
| Pattern | Components | Best For |
|---|---|---|
| MVC | Model-View-Controller | Web apps |
| MVP | Model-View-Presenter | Android |
| MVVM | Model-View-ViewModel | Data binding UIs |
| MVVM-C | + Coordinator | Navigation-heavy apps |
| VIPER | View-Interactor-Presenter-Entity-Router | Large iOS apps |
13.4 Design Patterns Cheat Sheet
Creational: Singleton, Factory, Abstract Factory, Builder, Prototype Structural: Adapter, Bridge, Composite, Decorator, Facade, Proxy Behavioral: Observer, Strategy, Command, State, Template Method, Iterator
13.5 Generative AI Architecture
Training pipeline: Pre-training on internet data -> Supervised fine-tuning -> Reward model training -> RLHF/PPO optimization
Inference: Input -> Content moderation -> Model -> Output moderation -> Response
Section 14: Data Pipelines & Processing
14.1 Data Pipeline (5 Phases)
- Collect - Acquire from data stores, streams, applications
- Ingest - Load into systems, organize in event queues
- Store - Data warehouses, lakes, lakehouses, databases
- Compute - Aggregate, cleanse, transform (batch + stream processing)
- Consume - Analytics, dashboards, ML, BI, self-service
Section 15: Payments & Commerce
15.1 Payments Ecosystem
Cardholder -> Merchant -> Payment Gateway -> Payment Processor -> Card Network -> Issuing Bank
Acquiring side: Merchant -> Acquiring bank/processor -> Card network Issuing side: Card network -> Issuing processor -> Issuing bank -> Validates customer
15.2 Visa Economics
$100 purchase: Merchant discount fee (~$2) -> Acquiring bank markup ($0.25) -> Issuing bank interchange ($1.75) -> Card network assessments (Visa: 0.11% + $0.0195/swipe)
15.3 QR Code / Scan-to-Pay
QR Generation (< 1 second): Cashier checkout -> PSP -> Generate QR URL -> Payment gateway -> Return to merchant -> Display QR
Payment (5 steps): Open wallet -> Scan QR -> Confirm -> PSP marks paid -> Notify merchant
Section 16: Search Engines
16.1 Search Engine Architecture (4 Steps)
- Crawling - Discover content via URL links
- Indexing - Parse, analyze, categorize content
- Ranking - Algorithms: keywords, relevance, quality, engagement, page speed
- Querying - Sift through index, return results
Section 17: Real-World Case Studies
17.1 Netflix Architecture
- Mobile/Web: Swift, Kotlin, React
- Frontend: GraphQL
- Backend: ZUUL (gateway), Eureka (service discovery), Spring Boot
- Databases: EVCache, Cassandra, CockroachDB
- Messaging: Apache Kafka, Flink
- Storage: S3, Open Connect CDN
- Data processing: Flink, Spark, Tableau, Redshift
- CI/CD: Jenkins, Gradle, Chaos Monkey, Spinnaker
Netflix API Evolution (4 stages)
Monolith -> Direct access -> Gateway aggregation -> Federated GraphQL (DGS)
Netflix Caching
EVCache distributed caching, CDN via Open Connect, app-level caching, DB query caching
17.2 Stack Overflow Architecture
- Serves ALL traffic with only 9 on-premise web servers running a monolith
- Does NOT run on cloud
- Proves monoliths can scale effectively
17.3 Discord Message Storage Evolution
MongoDB (2015, 100M messages) -> Cassandra (2017, billions) -> ScyllaDB (Cassandra-compatible, C++)
- p99 read: 15ms (ScyllaDB) vs 40-125ms (Cassandra)
- p99 write: 5ms (ScyllaDB) vs 5-70ms (Cassandra)
17.4 Reddit Architecture
- CDN: Fastly; Frontend: TypeScript/Node.js
- Backend: Python monolith -> Go microservices
- API: GraphQL Federation
- Data: Postgres + Memcached + Cassandra
- CDC: Debezium; Async: RabbitMQ + Kafka
- Infra: AWS + Kubernetes; CI/CD: Spinnaker, Drone CI, Terraform
17.5 Figma Postgres Scaling (3 Phases)
- Vertical Scaling + Replication (RDS upgrade + read replicas + PgBouncer)
- Vertical Partitioning (separate DBs for high-traffic tables)
- Horizontal Partitioning (split tables + custom DBProxy)
17.6 Pinterest Clone Time Optimization
One-line change that reduced clone times by 99%.
17.7 YouTube System Design
Upload: Request -> Raw video to object storage -> Metadata to DB/cache -> Transcoding (multiple resolutions) -> Transcoded to storage -> Notification via MQ -> Status update -> Streaming from CDN
Section 18: Memory & Storage
18.1 Memory Hierarchy (fastest to slowest)
- Registers - Ultra-fast CPU storage
- Caches (L1/L2/L3) - Small, fast, near CPU
- Main Memory (RAM) - Primary storage for running programs
- SSD - Fast persistent storage, no moving parts
- HDD - Mechanical, large capacity, long-term
- Remote Storage - Offsite backup, network accessible
Section 19: Redis
19.1 Redis Architecture Evolution
| Year | Version | Feature |
|---|---|---|
| 2010 | Initial | Standalone in-memory cache |
| 2013 | v2.8 | Persistence (RDB + AOF), Replication, Sentinel |
| 2015 | v3.0 | Cluster (16384 hash slots, sharding) |
| 2017 | v5.0 | Stream data type |
| 2020 | v6.0 | Multi-threaded I/O, ACLs, RESP3 |
| 2022 | v7.0 | Functions, multi-part AOF, sharded pub/sub |
| 2024 | v7.4 | License change: BSD-3 → RSALv2/SSPLv1 (source-available) |
| 2025 | v8.0 | Adds AGPLv3 option (OSI open source again); vector sets for AI/embeddings; modules (Search/JSON/TimeSeries/Bloom) merged into core |
License fork: Redis Inc.'s March 2024 relicensing (away from BSD-3) triggered the Linux Foundation to fork Redis 7.2.4 into Valkey (BSD, backed by AWS, Google, Oracle) — now the drop-in open-source default in Debian/Fedora and major clouds. Redis 8 (2025) restored an OSI-approved AGPLv3 option. Both are API-compatible.
Section 20: Web Performance
20.1 Website Speed Optimization
CDN, Image optimization, Browser caching, Minification, Lazy loading, Compression (gzip/brotli), Reduce HTTP requests, Async loading
20.2 Top 9 Website Performance Metrics
FCP, LCP, TTI, TBT, CLS, INP (replaced FID as a Core Web Vital in March 2024), TTFB, Speed Index. The three stable Core Web Vitals are now LCP, INP, CLS. (FID is deprecated/retired.)
20.3 Nginx Architecture
- Master-worker process model; event-driven non-blocking I/O
- Features: High-performance web server, Reverse proxy + load balancing, Content caching, SSL termination
Section 21: Monitoring & Observability
21.1 Linux Performance Observability Tools
Covers tools for: CPU (top, mpstat, perf), Memory (free, vmstat), Disk (iostat, iotop), Network (netstat, tcpdump, iftop)
21.2 Log Parsing Cheat Sheet
Common tools: grep, awk, sed, jq (JSON), ELK stack (Elasticsearch + Logstash + Kibana)
21.3 Diagnosing High Resource Usage
CPU: top, htop, perf; Memory: free, vmstat; I/O: iostat, iotop; Network: netstat, ss
Section 22: Development Lifecycle
22.1 SDLC Models
Iterative, Agile, Waterfall, Spiral, RAD (Rapid Application Development) - each with different risk management, flexibility, and feedback cycle characteristics.
22.2 Testing Best Practices
Unit testing, Integration testing, End-to-end testing, Performance testing, Security testing, Chaos testing
22.3 11 Steps: Junior to Senior Developer
Progressive growth through: code quality, system thinking, ownership, mentoring, cross-team influence, architecture decisions.
Section 23: Live Streaming
23.1 Live Streaming Architecture
Streamer -> Encoder -> Point-of-presence server -> Transcoding (multiple resolutions) -> Packaging (HLS format) -> CDN caching -> Viewer's player
Optional: Store in S3 for replay/VOD
PART II: DECISION FRAMEWORK LAYER
How to use this section: Given a requirement or constraint, follow the decision tree to arrive at a concrete technology/pattern choice. Every recomm
…(truncated)