Meaning: Ability of system to handle growth (users, data, traffic).
Types
- Vertical → Bigger machine
- Horizontal → More machines (preferred)
flowchart LR
User --> LB
LB --> S1
LB --> S2
LB --> S3
Meaning: System is accessible when needed.
Example: 99.99% uptime = ~52 min downtime/year
flowchart LR
User --> Primary
Primary --> Backup
Meaning: System works correctly over time (no data loss, correct results).
flowchart LR
User --> Service --> DB
DB --> BackupDB
| Term | Meaning |
|---|---|
| Latency | Time for one request |
| Throughput | Requests per second |
| Bandwidth | Data transfer capacity |
flowchart LR
User -->|"Latency"| Server
Server -->|"Throughput"| ManyUsers
flowchart LR
Client --> Server
Server --> Database
Persistent storage for data.
Types:
- Relational
- Key-value
- Document
- Graph
flowchart LR
App --> DB[(Database)]
| SQL | NoSQL |
|---|---|
| Structured | Flexible |
| ACID | BASE |
| Joins | Denormalized |
flowchart LR
App --> SQLDB[(SQL DB)]
App --> NoSQLDB[(NoSQL DB)]
Distributes traffic across servers.
flowchart LR
User --> LB
LB --> S1
LB --> S2
- Round Robin
- Least Connections
- IP Hash
flowchart LR
LB --> S1
LB --> S2
LB --> S3
Store frequently accessed data in fast storage.
flowchart LR
User --> Cache
Cache --> DB
Hardest problem 😄
Strategies:
- TTL
- Write-through
- Cache-aside
flowchart LR
App --> Cache
Cache --> DB
flowchart LR
User --> CDN
CDN --> OriginServer
Domain → IP resolution.
flowchart LR
Browser --> DNS
DNS --> ServerIP
Principles:
- Versioning
- Idempotency
- Pagination
- Error codes
flowchart LR
Client -->|GET/POST| REST_API
REST_API --> DB
| AuthN | AuthZ |
|---|---|
| Who are you | What can you access |
flowchart LR
User --> Server
Server --> SessionStore
flowchart LR
User -->|JWT| Server
- OAuth → Authorization delegation
- OAuth2 → Modern standard
- OIDC → Identity layer on OAuth2
flowchart LR
User --> AuthServer
AuthServer --> JWT
JWT --> API
Protects system from abuse.
flowchart LR
User --> RateLimiter --> API
flowchart LR
User --> OnlyServer
| HA | FT |
|---|---|
| Minimal downtime | Zero interruption |
Pick 2:
- Consistency
- Availability
- Partition Tolerance
- Strong
- Eventual
- Causal
flowchart LR
Node1 --> Node2
Node2 --> Node3
flowchart LR
Primary --> Replica1
Primary --> Replica2
flowchart LR
App --> PrimaryDB
App --> ReadReplica
Split data across DBs.
flowchart LR
Router --> Shard1
Router --> Shard2
Router --> Shard3
Horizontal → rows Vertical → columns
flowchart LR
Key --> HashRing
HashRing --> Node
Store duplicate data for faster reads.
flowchart LR
Query --> Index --> Data
flowchart LR
API --> UserService
API --> OrderService
API --> PaymentService
flowchart LR
Client --> Monolith --> DB
flowchart LR
User --> API_Gateway --> Lambda --> DB
flowchart LR
Producer --> EventBus --> Consumer
flowchart LR
Producer --> Queue --> Worker
flowchart LR
Publisher --> Topic
Topic --> Sub1
Topic --> Sub2
sequenceDiagram
Client->>Server: Request
Server-->>Client: Response
sequenceDiagram
Client->>Queue: Job
Worker->>Queue: Pull Job
Worker-->>Client: Done later
Traffic → DNS → CDN → Load Balancer → App → Cache → DB → Replicas → Backup