Foundations: Keeping It Alive — Platform & Ops
High Level Design·beginner·~25 min read
- basics
- observability
- kubernetes
- cloud
- auth
- Observability (Monitoring and Alerting) - Authentication Patterns - Kubernetes Core Concepts - Web Application Tier Architecture - Notification Platform Design - Application Performance Monitoring (APM) - Cloud Infrastructure Fundament…
What you'll learn
Observability (Monitoring and Alerting)
The Three Pillars
| Pillar | What | Tool Examples | |--------|------|--------------| | Metrics | Numerical time-series data (CPU, latency, error rate) | Prometheus, Datadog, CloudWatch | | Logs | Structured event records | ELK Stack, Splunk | | Traces | R…
Monitoring Architecture (Pull-Based)
Key metrics to monitor: - RED method (request-focused): Rate, Errors, Duration - USE method (resource-focused): Utilization, Saturation, Errors
Alerting Pyramid
SLO, SLI, and SLA
| Concept | Definition | Example | |---------|-----------|---------| | SLI (Service Level Indicator) | The actual measured metric | 99.3% of requests completed in Control Plane Components: - API Server -- The frontend to the cluster. All…
Pods
A Pod is the smallest deployable unit in Kubernetes. It represents one or more containers that share the same network namespace (same IP address) and storage volumes. Key characteristics: - Containers within a Pod communicate via localho…
ReplicaSets
A ReplicaSet ensures a specified number of Pod replicas are running at all times. If a Pod fails, the ReplicaSet controller creates a replacement. You rarely create ReplicaSets directly -- they are managed by Deployments.
Deployments
A Deployment is a higher-level abstraction that manages ReplicaSets and provides declarative updates to Pods. What Deployments add over raw ReplicaSets: - Rolling updates (gradually replace old Pods with new ones) - Rollback capability (…
Services
Pods are ephemeral and get new IP addresses when recreated. A Service provides a stable network endpoint (IP + DNS name) that routes traffic to a set of Pods selected by labels.
Kubernetes Networking Model
Kubernetes enforces a flat networking model with these fundamental rules: 1. Pod-to-Pod: Every Pod can communicate with every other Pod without NAT (Network Address Translation) 2. Node-to-Pod: Every Node can communicate with every Pod w…
Self-Hosted vs Managed Kubernetes
| Aspect | Self-Hosted | Managed (KaaS) | |--------|-------------|-----------------| | Setup | You provision VMs, install K8s, configure networking | Provider handles all infrastructure | | Maintenance | You patch OS, upgrade K8s version…
Web Application Tier Architecture
Application architecture can be classified by how its components are physically separated into distinct deployment units (tiers). This is different from layers (logical code separation) -- tiers represent actual physical/network separation.
Single-Tier (1-Tier)
The entire application -- UI, business logic, and database -- runs on a single machine. The user installs and runs everything locally. Examples: Desktop apps (MS Office, GIMP), mobile games with local saves, embedded systems Pros: No net…
Two-Tier (Client-Server)
The application is split into a client (typically UI + some logic) and a server (database or backend logic). Examples: Traditional desktop apps connecting to a shared database, thick-client banking applications Pros: Centralized data man…
Three-Tier
The most common web architecture. Separates concerns into three distinct tiers: - Presentation Tier -- Browser or mobile app; handles UI rendering - Application Tier -- Server-side logic; processes business rules, handles requests - Data…
N-Tier
Real-world systems extend beyond three tiers by adding specialized layers: Common additional tiers include: - Cache tier (Redis/Memcached) between app and database - Message queue tier (Kafka/RabbitMQ) for async processing - Search tier…
Layers vs Tiers
| Concept | Layer | Tier | |---------|-------|------| | Separation | Logical (within code) | Physical (separate machines/processes) | | Communication | Function/method calls | Network calls (HTTP, TCP, gRPC) | | Example | MVC pattern in…
Saga Pattern — Distributed Transactions Without 2PC
In microservice architectures, a business transaction often spans multiple services, each with its own database. Since 2PC is slow, blocking, and doesn't scale, the Saga pattern is the preferred alternative. Core idea: Break a distribute…
Notification Platform Design
A notification platform is a set of microservices that sends communication messages to users across multiple channels (SMS, Email, Push Notification, Webhooks, In-App).
Goals
- Fire and forget — async processing with automatic retry for intermittent failures - Ease of integration — internal services onboard through a standard API with API key authentication - Multi-channel — a single notification request can…
Architecture
Key Design Decisions
1. Priority Queues: Different clients get different priority levels. An OTP message from authentication service gets higher priority than a promotional campaign notification. Use separate queues or priority headers. 2. Vendor Fallback St…
Data Model
Non-Functional Requirements
- Availability: 99.99% uptime (notifications are often time-sensitive) - Latency: 4T - Score = (Satisfied + Tolerating/2) / Total samples Distributed Tracing: Tracks a single request as it flows through multiple microservices. Each servi…
Cloud Infrastructure Fundamentals
Regions and Availability Zones
Cloud providers organize infrastructure in a hierarchy designed for both performance and fault tolerance: | Concept | Definition | Design Impact | |---------|-----------|---------------| | Region | A cluster of data centers in a geograph…
Choosing Multi-AZ vs Multi-Region
| Strategy | Protects Against | Trade-off | |----------|-----------------|-----------| | Single AZ | Nothing (dev/test only) | Cheapest, simplest | | Multi-AZ (same region) | Hardware failure, power outage, natural disaster in one AZ | S…
Document Database Replication (Replica Sets)
In document databases, replication uses a replica set pattern — a group of database processes hosting the same data: | Node Type | Role | Data? | |-----------|------|-------| | Primary | Receives all write operations; records them in the…
Document Database Sharding
When a single replica set reaches hardware limits (RAM, CPU, disk), sharding distributes data across multiple replica sets: | Component | Purpose | |-----------|---------| | Router (mongos) | Routes queries to the correct shard(s); clien…
Database Cursors (Server-Side vs Client-Side)
A cursor is a mechanism for iterating over a large result set without loading all rows into memory at once. When a query returns millions of rows, the choice of cursor type determines where those rows are buffered and how they flow to yo…