Back-of-the-envelope EstimationSystem Design
QPS, storage और bandwidth का तेज़ order-of-magnitude गणित जो boxes बनाने से पहले ही डिज़ाइन को शामिल या बाहर कर देता है।
System Design की नींव →Algorithms, system design, distributed systems और AI के 59 शब्द — हर एक उस कोर्स से जुड़ा है जो उसे सिखाता है।
QPS, storage और bandwidth का तेज़ order-of-magnitude गणित जो boxes बनाने से पहले ही डिज़ाइन को शामिल या बाहर कर देता है।
System Design की नींव →विकल्पों पर depth-first search जो उम्मीदवार को कदम-दर-कदम बनाता है और हर कदम खोजने के बाद उसे undo करता है।
Recursion & Backtracking →Array में खोजने की बजाय संभावित जवाबों (capacity, speed, days) पर monotone feasibility check से binary search करना।
Binary Search →बहुत सारी requests एक साथ cache miss करती हैं (अक्सर expiry के बाद) और backing store को ओवरलोड कर देती हैं; locking, request coalescing या पहले refresh से बचाव।
Real-time और Streaming →Application पहले cache से पढ़ता है, miss पर database से लोड करता है और खुद cache भरता है।
System Design की नींव →Network partition के दौरान distributed system को consistency और availability में से एक चुनना पड़ता है।
Replication और Consistency Models →Content Delivery Network: भौगोलिक रूप से फैले caches जो static और cache योग्य content users के पास से परोसते हैं।
System Design की नींव →Error की सीमा पार होने पर fail होती dependency को बुलाना बंद कर देता है, जल्दी fail करता है और ठीक होने तक समय-समय पर जाँचता है।
Fault Tolerance और Graceful Degradation →Keys और nodes को एक ring पर रखना ताकि node जोड़ने या हटाने पर सिर्फ़ उसके पास की keys हिलें।
Partitioning और Sharding →एक request में model जितने tokens पर ध्यान दे सकता है उसकी अधिकतम संख्या, prompt और उसके अपने output सहित।
LLM की नींव →Conflict-free Replicated Data Type: ऐसा structure जिसके एक साथ हुए updates बिना coordination के हमेशा deterministic तरीके से merge होते हैं।
Replication और Consistency Models →एक queue जो बार-बार processing में fail होने वाले messages इकट्ठा करती है, ताकि मुख्य flow रोके बिना उनकी जाँच हो सके।
System Design की नींव →Non-negative weights वाले graphs पर single-source shortest paths, जो priority queue से सबसे नज़दीकी unvisited node को आगे बढ़ाता है।
Graph →हर transaction accounts में बराबर debit और credit दर्ज करता है, इसलिए balances हमेशा मेल खाते हैं — payment systems का आधार।
पैसा और Ledgers →टेक्स्ट (या images) का dense vector रूप, जिसमें अर्थ की समानता ज्यामितीय निकटता बन जाती है।
Retrieval-Augmented Generation (RAG) →Writes रुक जाएँ तो सभी replicas अंततः एक ही value पर पहुँचते हैं; बीच में reads पुराने हो सकते हैं।
Replication और Consistency Models →Greedy algorithms का proof तरीका: दिखाएँ कि किसी भी optimal समाधान के चुनाव को greedy चुनाव से बदलने पर वह कभी खराब नहीं होता।
Greedy →हर नई post को write के समय हर follower की पहले से बनी feed में डालना; reads तेज़, पर भारी following वाले accounts के लिए महँगा।
Real-time Fan-out और Push →अलग-अलग गति से चलने वाले दो pointers — cycles पकड़ने (Floyd's algorithm) और linked list का बीच खोजने में उपयोगी।
Linked List →Lock या lease के साथ दिया गया लगातार बढ़ता नंबर, ताकि storage उस holder के writes ठुकरा सके जिसका lease खत्म हो चुका।
Locks और Coordination →Model किसी घोषित tool के लिए structured arguments देता है, जिससे applications प्राकृतिक भाषा से असली काम कर सकें।
Prompt Engineering और Structured Output →Latitude/longitude को ऐसी string में बदलना जहाँ साझा prefix का मतलब पास के cells है — locations को index और query करने का सरल तरीका।
Location और Mobility →Hierarchical Navigable Small World graph: तेज़ approximate nearest-neighbour vector search का सबसे आम index।
Storage Engines और Indexing →Client द्वारा बनाई गई unique key जो request के परिणाम के साथ रखी जाती है, ताकि retries side effects दोहराने की बजाय मूल परिणाम लौटाएँ।
Idempotency और Exactly-once →Linear-time maximum subarray sum: हर index पर या तो पिछला subarray बढ़ाएँ या नए सिरे से शुरू करें।
Dynamic Programming →पहले से process हुए tokens के attention keys और values का संग्रह, ताकि generation हर कदम पूरा prefix दोबारा न गिने।
LLM Serving, लागत और Performance →हर event पर बढ़ने वाला और message मिलने पर merge होने वाला logical counter, जो causality के अनुरूप क्रम देता है।
Time, Clocks और Ordering →सबसे मज़बूत single-object consistency: हर operation अपनी शुरुआत और अंत के बीच किसी एक बिंदु पर atomically लागू होता दिखता है।
Replication और Consistency Models →Rubric के साथ एक model से दूसरे model के outputs को बड़े पैमाने पर जाँचना; human labels के साथ calibrate किया जाता है।
Evaluation और Guardrails →Log-Structured Merge tree: writes को memory में buffer करता है, sorted files flush करता है और उन्हें compact करता है — भारी write loads के लिए अनुकूलित।
Storage Engines और Indexing →Model Context Protocol: AI applications को एक साझा interface से tools, resources और prompts देने का खुला मानक।
Agents और Tool Use →Recursive call के परिणाम को उसके arguments के अनुसार cache करना ताकि overlapping subproblems एक ही बार गणना हों — top-down dynamic programming।
Dynamic Programming →बढ़ते या घटते क्रम में रखा stack; हर pop एक 'next greater / smaller element' प्रश्न को amortised O(1) में हल करता है।
Stack & Queue →Multi-agent पैटर्न जिसमें lead agent काम को तोड़ता है, उप-कार्य workers को देता है और उनके परिणाम जोड़ता है।
Agentic AI Systems और Orchestration →CAP का विस्तार: Partition हो तो Availability या Consistency चुनें; वरना (Else) Latency या Consistency चुनें।
Replication और Consistency Models →एक running total जिसमें prefix[i] पहले i elements का योग रखता है, इसलिए किसी भी range का योग prefix[r] − prefix[l] से O(1) में मिलता है।
Array →अविश्वसनीय input जो AI सिस्टम के निर्देशों को बदलने की कोशिश करता है — tools वाले agents के लिए मुख्य security चिंता।
AI System Design →एक tree जो 2D space को बार-बार चार हिस्सों में बाँटता है, और proximity search के लिए cell का आकार points की घनत्व के अनुसार बदलता है।
Location और Mobility →Model weights को कम bits (8-bit, 4-bit) में रखना ताकि थोड़ी सटीकता के बदले memory और लागत घटे।
LLM Serving, लागत और Performance →Read या write को स्वीकार करने वाले replicas की न्यूनतम संख्या; W + R > N होने पर reads नवीनतम write देखते हैं।
Replication और Consistency Models →समझने में आसान consensus algorithm, जो leader election, log replication और safety नियमों से बना है; etcd और Consul में उपयोग होता है।
Consensus और Leader Election →Retrieval-Augmented Generation: query के समय प्रासंगिक documents खोजकर model को दें ताकि जवाब आधारित और citable हों।
Retrieval-Augmented Generation (RAG) →एक दूसरा, ज़्यादा सटीक model (अक्सर cross-encoder) जो generation से पहले शीर्ष retrieved passages का क्रम बदलता है।
Retrieval-Augmented Generation (RAG) →एक agent पैटर्न जो काम पूरा होने तक reasoning steps को actions (tool calls) और observations के साथ बारी-बारी चलाता है।
Agents और Tool Use →लंबा transaction जो local steps में बँटा है, हर step के साथ एक compensating action जो बाद का step fail होने पर उसे undo करे।
Distributed Transactions →एक लगातार range जो invariant बनाए रखते हुए दाईं ओर बढ़ती और बाईं ओर सिकुड़ती है, जिससे subarray जवाब linear time में मिलते हैं।
Sliding Window →एक sampling parameter जो next-token distribution को तीखा (कम) या समतल (ज़्यादा) करता है — determinism के बदले विविधता।
LLM की नींव →Request से पहले streamed token तक की latency — chat interfaces में users को सबसे ज़्यादा महसूस होने वाला नंबर।
LLM Serving, लागत और Performance →वह इकाई जिसे language model पढ़ता और लिखता है — tokenizer से बना शब्द का टुकड़ा। लागत, latency और context limits tokens में गिने जाते हैं।
LLM की नींव →एक rate limiter जिसमें tokens तय दर से भरते हैं और हर request एक खर्च करती है, जिससे bucket size तक छोटे bursts संभव हैं।
Rate Limiting और Admission Control →Directed acyclic graph के nodes का ऐसा रैखिक क्रम जिसमें हर edge आगे की ओर इशारा करे; Kahn's BFS या DFS post-order से मिलता है।
Graph →बाहर जाने वाले event को state change वाले उसी transaction में outbox table में लिखना, फिर उसे broker तक भरोसे से पहुँचाना।
Distributed Transactions →Stream के निचले आधे के लिए max-heap और ऊपरी आधे के लिए min-heap, जिससे प्रति insert O(log n) में running median मिलता है।
Heap →दो indices जो sequence में चलते हैं — एक-दूसरे की ओर या एक ही दिशा में — ताकि nested loop की जगह एक pass काफ़ी हो।
Array →Coordinator सभी participants से पहले prepare, फिर commit करने को कहता है; nodes के पार atomic, पर coordinator fail होने पर अटक जाता है।
Distributed Transactions →Path compression और union by rank के साथ लगभग-स्थिर find और union operations वाला disjoint-set structure।
Graph →हर node के counters का vector जो बता सकता है कि दो events causally क्रम में हैं या concurrent।
Time, Clocks और Ordering →Stream processing में एक marker जो कहता है कि समय T से पुराने events की उम्मीद नहीं, ताकि windows बंद होकर परिणाम दें।
Stream Processing और Aggregation →Data pages बदलने से पहले लिखा गया append-only log, ताकि crash के बाद database committed बदलाव वापस पा सके।
Storage Engines और Indexing →