Week 12 — HLD Consistency & Communication

advanced hld dsa

Goal: “Distributed systems are easy — said no one ever.” — This week we tackle the hard parts of system design: consistency, availability, failure handling, and communication patterns. These are the topics that separate good answers from great ones in interviews.

Topics

DayTrackFocusTopics
MonA — DSA PracticeString DP & Interval DPSolve 2-3 problems. Try longest common subsequence, edit distance, and palindrome partitioning.
TueB — HLDConsistency & ScalingConsistent Hashing · ACID and Transactions · Horizontal vs Vertical Scaling · Microservices vs Monolith · API Gateway
WedA — DSA PracticeBinary Search on AnswerSolve 2-3 problems. Focus on problems where we binary search on the answer space — capacity to ship packages, split array largest sum, koko eating bananas.
ThuB — HLDStorage & ReliabilityDenormalization and Read-Write Separation · Blob Storage and Object Storage · CAP Theorem · Consistency Models · Failover and Redundancy
FriB — HLDResilience & CommunicationCircuit Breaker and Bulkhead · Monitoring, Logging, and Alerting · REST API Design · GraphQL · WebSockets

Key Concepts

  • Consistent hashing solves the “add/remove server” problem. In naive hashing, adding one server reshuffles almost everything. With consistent hashing, only K/N keys need to move (where K is total keys and N is total nodes). This is how DynamoDB, Cassandra, and CDNs distribute data.
  • Microservices give us independent deployment, scaling, and tech stack choices — but they add complexity in communication, data consistency, and debugging. Don’t default to microservices. Start monolith, extract services when the pain is real.
  • CAP theorem in practice: partition tolerance is non-negotiable in distributed systems, so the real choice is between consistency (CP) and availability (AP). Most systems are AP with eventual consistency — think DNS, social media feeds, shopping carts.
  • Circuit breaker prevents cascade failures in microservices. When a downstream service is failing, the circuit “opens” and we fail fast instead of waiting for timeouts. Bulkhead isolates failures — if one service is slow, it doesn’t eat up all our thread pool.
  • REST vs GraphQL vs WebSockets — each has its place. REST for CRUD APIs, GraphQL when clients need flexible queries (mobile apps with bandwidth constraints), WebSockets for real-time bidirectional communication (chat, live updates, gaming).

Practice

  • DSA: Solve 5-6 problems this week — string DP, interval DP, and binary search on answer
  • HLD: Design a notification system — when would we use polling vs SSE vs WebSockets? Draw the architecture for each approach and explain the trade-offs
  • HLD: Explain when we’d choose eventual consistency over strong consistency — give 3 real-world examples of each
  • HLD: Design a simple API gateway that handles authentication, rate limiting, and routing to 3 downstream microservices

~15 topics + DSA practice · ~2 hrs/day · Scaling, consistency, and communication protocols