ప్రతి large-scale application ఒకే రకమైన fundamental building blocks తో build అవుతుంది. Interviewers మీ నుండి కొత్త technology invent చేయమని expect చేయరు - ఇచ్చిన problem కి సరైన components ను select చేసి combine చేయగల సామర్థ్యం చూడాలనుకుంటారు. ఈ lesson లో ప్రతి design interview లో మీకు అవసరమయ్యే toolkit cover చేస్తాము.
Web యొక్క core model చాలా simple: clients requests పంపుతాయి, servers వాటిని process చేస్తాయి, responses తిరిగి వస్తాయి. కానీ modern systems లో scale, reliability మరియు performance handle చేయడానికి ఈ రెండు endpoints మధ్య అనేక layers ఉంటాయి.
ఒక typical request ఈ path ద్వారా వెళ్తుంది: client → CDN → load balancer → API gateway → application server → cache → database. ప్రతి layer ఒక specific problem solve చేస్తుంది, మరియు ఏ layer ఎప్పుడు అవసరం అనేది అర్థం చేసుకోవడమే strong candidates ను average వారి నుండి వేరు చేస్తుంది.
Interviews లో details లోకి వెళ్ళే ముందు ఎప్పుడూ high-level client-server flow sketch చేయండి. ఇది structured thinking చూపిస్తుంది.
ఒక single server కి limited capacity ఉంటుంది. Load balancers incoming requests ను ఈ strategies ద్వారా multiple servers కు distribute చేస్తాయి:
Load balancers health checks కూడా చేస్తాయి, unhealthy servers ను automatically pool నుండి తొలగిస్తాయి. Cloud environments లో AWS ALB లేదా Azure Front Door వంటి services ఇది transparently handle చేస్తాయి.
ఒక social media feed service writes కంటే 10 రెట్లు ఎక్కువ reads పొందుతుంది. Users consistently same cache-warm server ను reach అయ్యేలా ఏ load balancing approach బాగా ensure చేస్తుంది?
Caching frequently accessed data ను consumer కి దగ్గరగా store చేస్తుంది. ఇది అనేక levels లో ఉంటుంది:
| Layer | ఉదాహరణ | Latency | |-------|---------|---------| | Browser cache | Static assets, API responses | ~0ms | | CDN | Images, CSS, JS files | ~10-50ms | | Application cache | Redis, Memcached | ~1-5ms | | Database cache | Query result cache | ~5-10ms |
Sign in to join the discussion
Cache invalidation computing లో అత్యంత కష్టమైన problems లో ఒకటిగా ప్రసిద్ధి. Common strategies లో TTL (time-to-live), write-through (ప్రతి write తో cache update చేయడం), మరియు cache-aside (application cache ను explicitly manage చేయడం) ఉన్నాయి.
Phil Karlton యొక్క famous quote - "Computer Science లో రెండే hard things ఉన్నాయి: cache invalidation మరియు naming things" - ఇది ఎంత widely cite అవుతుందంటే, system design interviews లో ఇది ఒక rite of passage అయిపోయింది.
సరైన database ఎంచుకోవడం అత్యంత impactful design decisions లో ఒకటి:
SQL databases (PostgreSQL, MySQL) ACID transactions, strong consistency మరియు structured schemas అందిస్తాయి. Data లో clear relationships ఉన్నప్పుడు మరియు joins తో complex queries అవసరమైనప్పుడు ఇవి excel చేస్తాయి.
NoSQL databases అనేక రకాలుగా వస్తాయి:
మీరు frequently changing, semi-structured data (ప్రతి user type కు different fields) తో user profiles store చేసే system design చేస్తున్నారు. ఏ database type అత్యంత బాగా suit అవుతుంది?
ప్రతి operation కు immediate response అవసరం లేదు. Message queues (RabbitMQ, Apache Kafka, AWS SQS) producers ను consumers నుండి decouple చేస్తాయి, దీనివల్ల:
Kafka ప్రత్యేక mention కు అర్హం: ఇది కేవలం queue కాదు, ఒక distributed event log, ఇది event-driven architectures enable చేస్తుంది - ఇక్కడ multiple consumers independently same stream of events process చేయగలరు.
| అంశం | Monolith | Microservices | |------|----------|---------------| | Deployment | Single unit | Independent services | | Scaling | అంతా కలిసి scale | Individual services scale | | Complexity | ప్రారంభించడం సులభం | Operational overhead | | Data | Shared database | Database per service |
Monolith తో start చేయండి, అవసరమైనప్పుడు microservices extract చేయండి. చాలామంది interviewers microservices distributed system complexity (network failures, data consistency, deployment orchestration) తీసుకొస్తాయని acknowledge చేసే candidates ను appreciate చేస్తారు - ఇవి ఎల్లప్పుడూ సరైన choice కాదు.
Netflix అనేక సంవత్సరాలలో monolith నుండి microservices కు migrate చేసింది. కానీ Shopify - billions in transactions handle చేస్తూ - ఇప్పటికీ modular monolith ను run చేస్తుంది. ఒక company కి ఏ approach మెరుగు అనేది ఏ factors పై ఆధారపడవచ్చు?
CAP theorem ప్రకారం ఒక distributed system ఏకకాలంలో మూడింటిలో రెండు properties మాత్రమే guarantee చేయగలదు:
Distributed systems లో network partitions inevitable కాబట్టి, నిజమైన choice CP (consistency over availability) మరియు AP (availability over consistency) మధ్య ఉంటుంది.
మీరు ఒక banking transaction system design చేస్తున్నారు, ఇక్కడ incorrect balances financial loss కు కారణమవుతాయి. ఏ CAP trade-off prioritise చేయాలి?
System design interview లో ఈ structure follow చేయండి:
మీరు daily use చేసే system గురించి ఆలోచించండి - Instagram, Uber, లేదా Spotify. ఈ lesson లోని ఏ building blocks అది probably use చేస్తుందో గుర్తించగలరా? Load balancer ఎక్కడ ఉంటుంది? ఏమి cache అవుతుంది? ఏ database type దాని data model కు fit అవుతుంది?
తదుపరి lesson: ఈ fundamentals apply చేసి ఒక URL shortener ను scratch నుండి design చేద్దాం.