Cache static content at edge servers near users so it loads fast and the origin is spared, controlling freshness with TTL and invalidation.
CloudFront is AWS's global CDN wired to S3, load balancers, and edge functions, configured by cache behaviors with path patterns, TTL, origin failover, invalidation, signed-URL access control, and Shield DDoS protection.
Batch processes a bounded dataset in one high-throughput pass (Spark); streaming processes an unbounded event flow with low latency as it arrives (Flink/Kafka Streams).
SQL for ACID and relations, NoSQL for scale and flexible schema, cache for speed : choose by data model and access pattern, and usually combine them.
When the network partitions you must pick: CP rejects requests to stay correct, AP serves stale data to stay available, and most systems choose AP with eventual consistency while bank money chooses CP.
Place nodes and keys on a hash ring and assign each key to the next node clockwise, so adding or removing a node moves only a small slice of keys, not all of them.
Split rows across database instances by a shard key to scale beyond one machine, pick the key to balance load and keep queries single-shard, and plan for painful resharding.
Spread keys across nodes with consistent hashing, evict with LRU or LFU, keep entries fresh with invalidation, pick a write policy, and guard hot keys against stampedes.
Spread traffic across healthy servers using an algorithm, route by connection (L4) or by request content (L7), and never send traffic to a server that failed its health check.
Pull means the client keeps asking (polling, long-polling); push means the server delivers on its own (WebSocket, SSE, push notifications) : choose by latency, frequency, and direction.
Copy data to replicas for read scale and availability; master-slave has one writer, master-master has many writers needing conflict resolution, replicas lag, and failover promotes a replica when the primary dies.
SQL for ACID, relations, and complex queries; NoSQL for scale, flexible schema, and simple key-based access : choose by correctness needs versus scale and access pattern.
Strong consistency means every read sees the latest write (use for money); eventual consistency means replicas converge after a delay (fine for feeds and counts).
Sync (REST/gRPC) waits for an immediate answer but couples caller to callee; async (Kafka/SQS) hands off a message and decouples, trading immediacy for resilience.
Start with a monolith for simplicity and speed; move to microservices when scale, independent deployment, and team autonomy outweigh the added distributed-system complexity.
Build what differentiates you, buy commodity infrastructure, and judge by total cost of ownership and opportunity cost : "we can build it better" usually means "we will maintain it forever."