<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arslan Ahmad</title>
    <description>The latest articles on DEV Community by Arslan Ahmad (@arslan_ah).</description>
    <link>https://dev.to/arslan_ah</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F34147%2F2974e0a5-f688-45b5-a4c9-5fa49c257854.jpg</url>
      <title>DEV Community: Arslan Ahmad</title>
      <link>https://dev.to/arslan_ah</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arslan_ah"/>
    <language>en</language>
    <item>
      <title>How to Learn System Design in 2027: The Best Resources, in the Order You Should Use Them</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Thu, 26 Nov 2026 08:25:56 +0000</pubDate>
      <link>https://dev.to/arslan_ah/how-to-learn-system-design-in-2027-the-best-resources-in-the-order-you-should-use-them-1i94</link>
      <guid>https://dev.to/arslan_ah/how-to-learn-system-design-in-2027-the-best-resources-in-the-order-you-should-use-them-1i94</guid>
      <description>&lt;p&gt;Most "awesome system design resources" lists have the same problem.&lt;/p&gt;

&lt;p&gt;They hand you 20 links and wish you luck.&lt;/p&gt;

&lt;p&gt;You bookmark everything. You open three tabs. You read half a chapter of a 600-page book. Then you stall, because nobody told you what to read &lt;strong&gt;first&lt;/strong&gt;, what to &lt;strong&gt;skip&lt;/strong&gt;, or how to know when you are &lt;strong&gt;ready&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I spent years as a hiring manager at Meta and Microsoft. I have watched hundreds of engineers walk into system design rounds. The ones who struggled rarely lacked resources. They lacked &lt;strong&gt;order&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So this is not another pile of links.&lt;/p&gt;

&lt;p&gt;It is a learning path. Every resource below sits in the stage where it does the most good. You will also get a 10-week plan, a simple study loop that makes the material stick, and the mistakes that waste the most time.&lt;/p&gt;

&lt;p&gt;Let's get into it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5i7t1hgvtm7nwj7v004g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5i7t1hgvtm7nwj7v004g.png" alt="The 4-stage system design learning roadmap" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why order matters more than the list
&lt;/h2&gt;

&lt;p&gt;Think of system design like learning to cook.&lt;/p&gt;

&lt;p&gt;A recipe book is useless if you do not know what "sauté" means. And knife skills alone will not get you through a dinner rush.&lt;/p&gt;

&lt;p&gt;System design works the same way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Concepts first.&lt;/strong&gt; What is a load balancer? Why do we cache?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Depth second.&lt;/strong&gt; Why does replication lag happen? What does "consistency" actually promise?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real systems third.&lt;/strong&gt; How did Discord store trillions of messages?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice last.&lt;/strong&gt; Can you design one yourself in 45 minutes, out loud?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Jump to stage 4 too early and you memorize answers you cannot defend. Stay in stage 2 forever and you know a lot but never ship a design.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 1: Foundations (Weeks 1-2)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt; Learn the vocabulary. You should be able to explain each building block in one sentence.&lt;/p&gt;

&lt;p&gt;Topics to cover: client-server basics, DNS, load balancers, caching, CDNs, SQL vs NoSQL, replication, sharding, message queues, and rough latency numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best resources for this stage:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/donnemartin/system-design-primer" rel="noopener noreferrer"&gt;System Design Primer&lt;/a&gt;&lt;/strong&gt; (GitHub). The most-starred system design repo on GitHub, with 370K+ stars. Use it as a &lt;strong&gt;map&lt;/strong&gt;, not a novel. Skim the index and read the sections on whatever confuses you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.youtube.com/@designgurus1173" rel="noopener noreferrer"&gt;Design Gurus on YouTube&lt;/a&gt;&lt;/strong&gt;. Short video explainers on system design concepts. Perfect for 10-minute sessions on your phone. Watch at 1.5x, pause, and predict the next step before it is explained.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals" rel="noopener noreferrer"&gt;Grokking System Design Fundamentals&lt;/a&gt;&lt;/strong&gt; (DesignGurus.io). A beginner-friendly, text-based course on the core building blocks: load balancing, caching, databases, and more. Each lesson explains what problem a concept solves, what it costs you, and where it fits. Good if you want structure instead of jumping between repos.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/blog/Back-of-the-Envelope-System-Design-Interview" rel="noopener noreferrer"&gt;Back-of-the-Envelope Estimation Guide&lt;/a&gt;&lt;/strong&gt; (DesignGurus.io blog). The latency and capacity numbers every engineer should know, plus QPS, storage, and bandwidth math. Memorize the orders of magnitude. Memory is fast, disk is slow, a cross-continent round trip is very slow. That single intuition settles half of all design debates.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;New to all of this? Start with this &lt;a href="https://www.designgurus.io/blog/system-design-for-beginners" rel="noopener noreferrer"&gt;system design for beginners roadmap&lt;/a&gt; first. It covers the five concepts to learn before anything else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You are done with stage 1 when:&lt;/strong&gt; you can explain why a cache helps, when it hurts, and what "cache invalidation" means, without looking anything up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 2: Depth on the building blocks (Weeks 3-6)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt; Understand the &lt;strong&gt;trade-offs&lt;/strong&gt;. Interviewers do not care that you know Cassandra exists. They care that you know &lt;strong&gt;why&lt;/strong&gt; you would pick it, and what you give up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best resources for this stage:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://martin.kleppmann.com/2026/03/24/designing-data-intensive-applications-2e.html" rel="noopener noreferrer"&gt;Designing Data-Intensive Applications, 2nd Edition&lt;/a&gt;&lt;/strong&gt; by Martin Kleppmann and Chris Riccomini. The classic just got a full rewrite. If you read one book on this list, make it this one. Focus on the chapters on replication, partitioning, transactions, and consistency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://understandingdistributed.systems/" rel="noopener noreferrer"&gt;Understanding Distributed Systems&lt;/a&gt;&lt;/strong&gt; by Roberto Vitillo. Shorter and more practical than DDIA. A great bridge if DDIA feels heavy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Martin Kleppmann's Distributed Systems lecture series&lt;/strong&gt; (YouTube). Free Cambridge lectures. Clear explanations of clocks, replication, and consensus.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/blog/consistency-patterns-distributed-systems" rel="noopener noreferrer"&gt;Consistency Patterns in Distributed Systems&lt;/a&gt;&lt;/strong&gt; (DesignGurus.io blog). Strong, eventual, causal, read-your-writes, and monotonic consistency, with real database examples. Read it right after the DDIA chapter on replication.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; Do not read DDIA cover to cover in one go. Read one chapter, then go back to the stage 1 resources and see how much more makes sense. That back-and-forth is where real understanding happens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You are done with stage 2 when:&lt;/strong&gt; you can explain the difference between strong and eventual consistency using a real example, like a bank balance vs a like counter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 3: Learn from real systems (Weeks 5-8, overlapping)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt; See how real companies made real trade-offs under real pressure. This is what separates "textbook answers" from senior-level answers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best resources for this stage:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://discord.com/blog/how-discord-stores-trillions-of-messages" rel="noopener noreferrer"&gt;How Discord Stores Trillions of Messages&lt;/a&gt;&lt;/strong&gt;. A perfect case study: a database migration, hot partitions, and a request-coalescing service in front of the database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://aws.amazon.com/builders-library/" rel="noopener noreferrer"&gt;Amazon Builders' Library&lt;/a&gt;&lt;/strong&gt;. Senior Amazon engineers on timeouts, retries, backoff, load shedding, and caching. Pure gold for "what happens when things fail" questions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://netflixtechblog.com/" rel="noopener noreferrer"&gt;Netflix Tech Blog&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;a href="https://www.uber.com/blog/engineering/" rel="noopener noreferrer"&gt;Uber Engineering&lt;/a&gt;&lt;/strong&gt;, and the &lt;strong&gt;&lt;a href="https://blog.cloudflare.com/" rel="noopener noreferrer"&gt;Cloudflare Blog&lt;/a&gt;&lt;/strong&gt;. Pick one post a week. Read it, then sketch the architecture from memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/binhnguyennus/awesome-scalability" rel="noopener noreferrer"&gt;Awesome Scalability&lt;/a&gt;&lt;/strong&gt; (GitHub). A huge index of engineering blog posts grouped by topic. Use it when you want real-world examples of a specific pattern.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The classic papers.&lt;/strong&gt; Short list: &lt;a href="https://www.allthingsdistributed.com/files/amazon-dynamo-sosp2007.pdf" rel="noopener noreferrer"&gt;Amazon Dynamo&lt;/a&gt;, Google File System, MapReduce, Bigtable, Kafka, Spanner, and &lt;a href="https://raft.github.io/raft.pdf" rel="noopener noreferrer"&gt;Raft&lt;/a&gt;. Read the abstract, the architecture section, and the "lessons learned." You do not need every proof.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;You are done with stage 3 when:&lt;/strong&gt; you can tell the story of one real system in two minutes. What broke, what they changed, and what it cost them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 4: Interview practice (Weeks 7-10)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt; Turn knowledge into a &lt;strong&gt;performance&lt;/strong&gt;. A system design interview is a 45-minute conversation. You need a repeatable framework and lots of reps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best resources for this stage:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt;&lt;/strong&gt; (DesignGurus.io). A step-by-step approach to open-ended design questions, with full walkthroughs of classic problems like URL shorteners and social media feeds. Full disclosure: I created the original version of this course, so I am biased. But it exists because I kept seeing strong engineers fail for lack of a framework, not lack of knowledge.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/design-gurus/grokking-system-design" rel="noopener noreferrer"&gt;Grokking System Design on GitHub&lt;/a&gt;&lt;/strong&gt;. The free, open companion to the course. Pattern guides, practice questions, and cheat sheets you can read in the browser, no account needed. Star it and use the cheat sheets for last-week review.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/blog/system-design-mastery-your-roadmap-to-acing-interviews" rel="noopener noreferrer"&gt;The Complete System Design Interview Guide&lt;/a&gt;&lt;/strong&gt; (DesignGurus.io blog). A 7-step framework for any design question, with the core concepts and common questions in one place. Read it before your first mock.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mock interviews.&lt;/strong&gt; Nothing replaces doing it out loud with another person. Trade sessions with a friend, or book a mock with an experienced interviewer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;You are done with stage 4 when:&lt;/strong&gt; you can take an unseen question, clarify requirements, estimate scale, sketch a design, and defend two trade-offs, all within 45 minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Going further (after the interview, or for senior roles)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://sre.google/books/" rel="noopener noreferrer"&gt;Site Reliability Engineering&lt;/a&gt;&lt;/strong&gt; by Google. Free online. How large systems are actually operated: SLOs, monitoring, incident response.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Building Microservices (2nd Edition)&lt;/strong&gt; by Sam Newman. Service boundaries, communication patterns, and migrating away from a monolith.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://pdos.csail.mit.edu/6.824/" rel="noopener noreferrer"&gt;MIT 6.5840 Distributed Systems&lt;/a&gt;&lt;/strong&gt;. Free lectures and labs. You will implement Raft yourself. Hard, but nothing builds intuition faster.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Pick the right format for the job
&lt;/h2&gt;

&lt;p&gt;Not every resource type does the same job. Use each one for what it is best at.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj73p87fpnwc319grr8au.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj73p87fpnwc319grr8au.png" alt="Which resource format to use for which job" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Format&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;th&gt;Watch out for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;GitHub repos&lt;/td&gt;
&lt;td&gt;Quick reference and review&lt;/td&gt;
&lt;td&gt;Easy to skim without learning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Courses&lt;/td&gt;
&lt;td&gt;Structure and a clear path&lt;/td&gt;
&lt;td&gt;Passive reading without practice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Books&lt;/td&gt;
&lt;td&gt;Deep understanding of trade-offs&lt;/td&gt;
&lt;td&gt;Too slow as your &lt;strong&gt;first&lt;/strong&gt; resource&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Engineering blogs&lt;/td&gt;
&lt;td&gt;Real-world decisions&lt;/td&gt;
&lt;td&gt;Company-specific context&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Papers&lt;/td&gt;
&lt;td&gt;Where the big ideas came from&lt;/td&gt;
&lt;td&gt;Getting lost in proofs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Videos&lt;/td&gt;
&lt;td&gt;Intuition and visuals&lt;/td&gt;
&lt;td&gt;Feels like learning, often isn't&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mock interviews&lt;/td&gt;
&lt;td&gt;Performance under pressure&lt;/td&gt;
&lt;td&gt;Useless without feedback&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The study loop that makes it stick
&lt;/h2&gt;

&lt;p&gt;Here is the single biggest upgrade to how you study.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Design first. Read second.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before you read how someone designed a URL shortener, spend 20 minutes designing it yourself. On paper. Badly.&lt;/p&gt;

&lt;p&gt;Then read the solution and compare. The gaps you find are exactly what you need to learn. Your brain remembers answers to questions it already asked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnxvh2ophf6g1ls5o2h5d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnxvh2ophf6g1ls5o2h5d.png" alt="The design-first study loop" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Attempt.&lt;/strong&gt; Design it yourself for 20 to 30 minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compare.&lt;/strong&gt; Read a strong solution. Circle every difference.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fill gaps.&lt;/strong&gt; Go back to stage 1 and 2 resources for the concepts you missed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explain.&lt;/strong&gt; Walk through the design out loud as if to an interviewer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Run this loop on 10 to 15 classic problems and you will be in great shape.&lt;/p&gt;

&lt;h2&gt;
  
  
  5 mistakes that waste the most time
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Collecting instead of studying.&lt;/strong&gt; Bookmarking 50 links feels productive. It is not. Pick one resource per stage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Starting with the hardest book.&lt;/strong&gt; DDIA is brilliant, but it is not a first resource. Learn the vocabulary first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memorizing designs.&lt;/strong&gt; Interviewers change one requirement and memorized answers fall apart. Learn the &lt;strong&gt;why&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skipping estimation.&lt;/strong&gt; Back-of-the-envelope math (requests per second, storage per year) drives every design choice. Practice it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never practicing out loud.&lt;/strong&gt; Knowing a design and explaining it under time pressure are two different skills.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Want the full list? Here are &lt;a href="https://www.designgurus.io/blog/system-design-interview-mistakes" rel="noopener noreferrer"&gt;10 system design interview mistakes that cost you the offer&lt;/a&gt;, with a fix for each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  A 10-week plan at a glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Weeks&lt;/th&gt;
&lt;th&gt;Focus&lt;/th&gt;
&lt;th&gt;Time per day&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1-2&lt;/td&gt;
&lt;td&gt;Foundations: building blocks and vocabulary&lt;/td&gt;
&lt;td&gt;45 min&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3-6&lt;/td&gt;
&lt;td&gt;Depth: DDIA chapters plus one supporting resource&lt;/td&gt;
&lt;td&gt;60 min&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5-8&lt;/td&gt;
&lt;td&gt;Real systems: one case study and one paper per week&lt;/td&gt;
&lt;td&gt;30 min (overlaps)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7-10&lt;/td&gt;
&lt;td&gt;Practice: two to three full mock designs per week&lt;/td&gt;
&lt;td&gt;60-90 min&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Short on time? Compress stages 1 and 2 into four weeks and lean harder on structured courses. Have more time? Add the MIT labs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Order beats volume.&lt;/strong&gt; Concepts, then depth, then real systems, then practice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One resource per stage is enough.&lt;/strong&gt; Go deep, not wide.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DDIA (2nd Edition) is the best single book&lt;/strong&gt;, but read it after you know the basics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Engineering blogs and papers&lt;/strong&gt; are where textbook answers turn into senior-level answers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Design first, read second.&lt;/strong&gt; Attempting a problem before reading the solution is the fastest way to learn.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice out loud.&lt;/strong&gt; A system design interview is a conversation, not a written exam.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How long does it take to learn system design?&lt;/strong&gt;&lt;br&gt;
For interview readiness, most engineers need 8 to 12 weeks at about an hour a day. Mastery for real-world architecture takes years of building and operating systems. The good news: you do not need mastery to pass the interview.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can I learn system design without distributed systems experience?&lt;/strong&gt;&lt;br&gt;
Yes. Most candidates have never run a system at Google scale. Interviewers test your reasoning about trade-offs, not your production history. Start with the foundations and use case studies to fill the experience gap.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the best free resource to learn system design?&lt;/strong&gt;&lt;br&gt;
The System Design Primer on GitHub is the best free starting map. Pair it with the free &lt;a href="https://github.com/design-gurus/grokking-system-design" rel="noopener noreferrer"&gt;Grokking System Design repo&lt;/a&gt; for interview patterns and the Amazon Builders' Library for real-world depth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Should I read Designing Data-Intensive Applications before my interview?&lt;/strong&gt;&lt;br&gt;
Read the key chapters (replication, partitioning, transactions, consistency) if you have four or more weeks. If your interview is in two weeks, focus on a structured interview course and practice instead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What do interviewers actually look for in a system design round?&lt;/strong&gt;&lt;br&gt;
Clear requirements, sensible scale estimates, a working high-level design, and honest trade-offs. Saying "I chose X, which costs us Y, and here is when I would switch to Z" beats a perfect diagram every time.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What would you add to this list?&lt;/strong&gt; Drop your favorite system design resource in the comments. I read every one, and I will add the best suggestions to this post.&lt;/p&gt;

&lt;p&gt;If this helped, a ❤️ or a bookmark helps other engineers find it too.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>programming</category>
      <category>career</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Single Point of Failure: Why One Box Can Take Down Your Whole System (and How to Fix It)</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Thu, 19 Nov 2026 21:06:49 +0000</pubDate>
      <link>https://dev.to/arslan_ah/single-point-of-failure-why-one-box-can-take-down-your-whole-system-and-how-to-fix-it-3m1p</link>
      <guid>https://dev.to/arslan_ah/single-point-of-failure-why-one-box-can-take-down-your-whole-system-and-how-to-fix-it-3m1p</guid>
      <description>&lt;p&gt;You added three app servers. You put a load balancer in front of them. You feel good about your architecture.&lt;/p&gt;

&lt;p&gt;Then the database server reboots for a kernel patch, and your entire product goes dark for 20 minutes.&lt;/p&gt;

&lt;p&gt;That's a &lt;strong&gt;single point of failure (SPOF)&lt;/strong&gt;, and it's one of the most common reasons "highly available" systems turn out to be anything but. In this post, we'll go beyond the textbook definition and cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What a SPOF really is (and why redundancy upstream doesn't save you)&lt;/li&gt;
&lt;li&gt;The availability math that shows exactly how much a SPOF costs you&lt;/li&gt;
&lt;li&gt;The hidden SPOFs most teams miss: DNS, config, certificates, people&lt;/li&gt;
&lt;li&gt;Concrete patterns to eliminate them, and their trade-offs&lt;/li&gt;
&lt;li&gt;A step-by-step method to hunt SPOFs in any design&lt;/li&gt;
&lt;li&gt;How to talk about SPOFs in a system design interview&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's dive in.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is a Single Point of Failure?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;single point of failure&lt;/strong&gt; is any component whose failure, on its own, makes the whole system (or a critical feature) unavailable.&lt;/p&gt;

&lt;p&gt;The key words are &lt;em&gt;on its own&lt;/em&gt;. If one thing breaking is enough to take you down, that thing is a SPOF.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6v2b0a96gltgfxcdh5im.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6v2b0a96gltgfxcdh5im.png" alt="Diagram showing users and a load balancer feeding three app servers that all depend on a single database instance" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Look at the diagram above. Three app servers &lt;em&gt;look&lt;/em&gt; resilient. But every request eventually funnels into one database. Kill that box, and 100% of requests fail.&lt;/p&gt;

&lt;p&gt;This is the trap: &lt;strong&gt;redundancy in one layer doesn't help if another layer is still singular.&lt;/strong&gt; Availability is only as strong as the weakest layer in the request path.&lt;/p&gt;

&lt;p&gt;A SPOF isn't always a server, either. It can be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A component:&lt;/strong&gt; one database, one load balancer, one message broker&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A location:&lt;/strong&gt; one data center, one availability zone, one region&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A dependency:&lt;/strong&gt; one DNS provider, one payment gateway, one identity provider&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A process:&lt;/strong&gt; one deploy pipeline, one config push that hits every server at once&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A person:&lt;/strong&gt; the one engineer who knows how the billing system works&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why SPOFs Matter: The Math
&lt;/h2&gt;

&lt;p&gt;Most articles stop at "SPOFs are bad for reliability." Let's actually put numbers on it, because this is where the intuition clicks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fty520e8iz8646qt5i2wt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fty520e8iz8646qt5i2wt.png" alt="Availability math comparing components in series (about 99.79 percent) versus two redundant database copies in parallel (about 99.9999 percent)" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Components in series multiply
&lt;/h3&gt;

&lt;p&gt;When a request has to pass through several components and &lt;em&gt;each one must work&lt;/em&gt;, you multiply their availabilities:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Load balancer (99.99%) × App tier (99.9%) × Database (99.9%)
= 0.9999 × 0.999 × 0.999
≈ 0.9979  →  99.79% available
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's roughly &lt;strong&gt;18 hours of downtime per year&lt;/strong&gt;, and it's &lt;em&gt;worse&lt;/em&gt; than any individual component. Every SPOF you add to the chain drags the whole system down.&lt;/p&gt;

&lt;h3&gt;
  
  
  Redundant components compound
&lt;/h3&gt;

&lt;p&gt;Now put two database copies side by side, where &lt;em&gt;either one&lt;/em&gt; can serve traffic. The system only fails if &lt;em&gt;both&lt;/em&gt; fail at the same time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 − (0.001 × 0.001) = 0.999999  →  99.9999% available
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's about &lt;strong&gt;30 seconds of downtime per year&lt;/strong&gt; for the database layer, from two components that are each "only" 99.9%.&lt;/p&gt;

&lt;h3&gt;
  
  
  The catch nobody mentions
&lt;/h3&gt;

&lt;p&gt;That parallel formula assumes the copies &lt;strong&gt;fail independently&lt;/strong&gt;. If both replicas sit in the same rack, share a power supply, run the same buggy config, or live in the same region, they'll fail together, and you're back to a single point of failure wearing a disguise.&lt;/p&gt;

&lt;p&gt;This is why senior engineers talk about &lt;strong&gt;failure domains&lt;/strong&gt;, not just copies. Two servers in one failure domain is still one failure domain.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Obvious SPOFs
&lt;/h2&gt;

&lt;p&gt;These are the ones every tutorial lists, and for good reason:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Why it's a SPOF&lt;/th&gt;
&lt;th&gt;Typical fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Database&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;All reads and writes depend on it&lt;/td&gt;
&lt;td&gt;Primary + replicas, automatic failover, or a distributed DB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Load balancer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Every request passes through it&lt;/td&gt;
&lt;td&gt;Pair of LBs (active-passive with a floating IP) or a managed, multi-AZ LB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;App server&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;One process serving all users&lt;/td&gt;
&lt;td&gt;Stateless servers behind an LB, auto-scaling group with N+1 capacity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Network link&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;One path to the internet&lt;/td&gt;
&lt;td&gt;Multiple ISPs / uplinks, multiple AZs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cache&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;If the app can't function without it, it's critical&lt;/td&gt;
&lt;td&gt;Replicated cache cluster, and graceful fallback to the DB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A note on caches: a cache shouldn't be a SPOF by design, but it often becomes one. If your database can't handle the traffic when the cache goes cold, then the cache &lt;em&gt;is&lt;/em&gt; in your critical path. Plan for a "cache is down" scenario.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hidden SPOFs (Where Real Outages Come From)
&lt;/h2&gt;

&lt;p&gt;Here's where this post goes further than most. In practice, big outages rarely come from "the database server died." They come from things nobody drew on the architecture diagram.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftirguwpda2p053soyma5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftirguwpda2p053soyma5.png" alt="Grid of ten hidden single points of failure: DNS, TLS certificates, config and feature flags, auth and identity, single AZ or region, message broker, CI/CD, third-party APIs, secrets and KMS, and the one engineer" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. DNS.&lt;/strong&gt; If your DNS provider (or your DNS config) breaks, nobody can find your servers, even if every one of them is healthy. In October 2021, a faulty network configuration change at Facebook made its DNS servers unreachable, and Facebook, Instagram, and WhatsApp went offline for roughly six hours. Internal tools broke too, slowing recovery.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Configuration and deployments.&lt;/strong&gt; A bad config or code push that reaches every server at once turns your redundant fleet into a single point of failure. The July 2024 CrowdStrike incident is the textbook example: one faulty content update crashed millions of Windows machines worldwide at the same time. Redundancy doesn't help when every copy receives the same bug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. A single region.&lt;/strong&gt; Multi-AZ protects you from a data center failure, not from a regional problem. Large regional outages at major cloud providers (including a widely felt AWS us-east-1 incident in October 2025 tied to DNS resolution for a core database service) have shown how many products quietly depend on one region, or on a "global" service that actually lives in one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Certificates and secrets.&lt;/strong&gt; If all your TLS certificates expire on the same day, or every service needs one secrets store at startup, that's a SPOF on a timer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Shared infrastructure.&lt;/strong&gt; One Kafka cluster that every service publishes to. One Redis used for sessions, rate limiting, &lt;em&gt;and&lt;/em&gt; queues. One auth service every request has to call. Microservices don't remove SPOFs on their own; they often just move them into shared platform components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Third-party APIs.&lt;/strong&gt; Your system might be multi-region, but your payment provider, email service, or LLM API might not be. If checkout dies when one vendor dies, that vendor is your SPOF.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. People and knowledge.&lt;/strong&gt; If only one person can operate, debug, or deploy a system, you have a bus-factor problem. Runbooks, on-call rotation, and shared ownership are reliability work too.&lt;/p&gt;




&lt;h2&gt;
  
  
  Strategies to Eliminate SPOFs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Redundancy (N+1 and beyond)
&lt;/h3&gt;

&lt;p&gt;Run more copies than you need. &lt;strong&gt;N+1&lt;/strong&gt; means you can lose one instance and still handle full load. &lt;strong&gt;N+2&lt;/strong&gt; lets you lose one during a planned deploy &lt;em&gt;and&lt;/em&gt; survive an unplanned failure at the same time.&lt;/p&gt;

&lt;p&gt;The important part: redundant copies need enough &lt;strong&gt;spare capacity&lt;/strong&gt;. If you run two servers at 70% CPU each, losing one means the survivor needs 140%. That's not redundancy, that's a cascading failure waiting to happen.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Failover: Active-Passive vs. Active-Active
&lt;/h3&gt;

&lt;p&gt;Redundancy only helps if traffic actually moves to the healthy copy. That's failover, and there are two main flavors:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw17e0iwjej9qzr6h14k7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw17e0iwjej9qzr6h14k7.png" alt="Comparison of active-passive failover, with a primary serving all traffic and an idle standby, versus active-active, with two nodes each serving half the traffic" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Active-Passive&lt;/th&gt;
&lt;th&gt;Active-Active&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;How it works&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Primary serves traffic; standby takes over on failure&lt;/td&gt;
&lt;td&gt;All nodes serve traffic simultaneously&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Failover time&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Seconds to minutes (detect + promote)&lt;/td&gt;
&lt;td&gt;Near-instant (survivors already live)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cost&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Standby capacity sits mostly idle&lt;/td&gt;
&lt;td&gt;All capacity is used&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Complexity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Simpler, easier strong consistency&lt;/td&gt;
&lt;td&gt;Harder: write conflicts, data sync&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Good fit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Relational DB primaries, stateful services&lt;/td&gt;
&lt;td&gt;Stateless app tiers, CDNs, multi-region reads&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Watch out for split-brain.&lt;/strong&gt; In active-passive setups, if the network between primary and standby breaks, both might think the other is dead and both start accepting writes. The standard fix is a &lt;strong&gt;quorum&lt;/strong&gt;: use an odd number of nodes (3, 5) and only allow the side with a majority to act as primary. That's why tools like etcd, ZooKeeper, and Raft-based databases run in groups of three or five.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Redundant Load Balancing
&lt;/h3&gt;

&lt;p&gt;A single load balancer is a classic hidden SPOF. Fix it with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A pair of load balancers&lt;/strong&gt; sharing a floating/virtual IP (e.g., keepalived with VRRP) in active-passive mode&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A managed cloud load balancer&lt;/strong&gt; that is already distributed across zones&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DNS-level distribution&lt;/strong&gt; across multiple load balancers or regions, with health checks&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Data Replication
&lt;/h3&gt;

&lt;p&gt;For stateful components, redundancy means replication:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Synchronous replication:&lt;/strong&gt; a write isn't confirmed until the replica has it. No data loss on failover, but higher write latency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asynchronous replication:&lt;/strong&gt; faster writes, but the replica may lag. On failover, you can lose the most recent writes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the trade-off between &lt;strong&gt;RPO&lt;/strong&gt; (how much data you can afford to lose) and latency. In an interview, naming that trade-off out loud is a strong signal.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Spread Across Failure Domains
&lt;/h3&gt;

&lt;p&gt;Put copies in different racks, availability zones, and (for critical systems) regions. Here's what a basic SPOF-free setup looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxmn3vlcjmdbrln8ejkka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxmn3vlcjmdbrln8ejkka.png" alt="Reference architecture with DNS across two providers plus a CDN, routing to two availability zones, each with its own load balancer and two app servers, and a primary database in zone A synchronously replicating to an auto-promoting replica in zone B" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every layer has at least two copies, and the copies don't share a failure domain.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Limit the Blast Radius of Changes
&lt;/h3&gt;

&lt;p&gt;Since config and deploys are a top cause of outages, treat change as a failure source:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Canary and staged rollouts:&lt;/strong&gt; ship to 1%, then 10%, then everyone&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Feature flags with kill switches&lt;/strong&gt; so you can turn off a bad change without redeploying&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cell-based architecture:&lt;/strong&gt; split users into independent "cells" so a bad push or noisy tenant only affects one slice&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Graceful Degradation
&lt;/h3&gt;

&lt;p&gt;Not every dependency needs to be redundant. Sometimes the right answer is to &lt;strong&gt;fail softly&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recommendations service down? Show popular items instead.&lt;/li&gt;
&lt;li&gt;Cache down? Serve from the DB with tighter rate limits.&lt;/li&gt;
&lt;li&gt;Third-party API slow? Use &lt;strong&gt;timeouts, retries with backoff, and circuit breakers&lt;/strong&gt; so one slow dependency doesn't exhaust your threads and take everything else down with it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A non-critical feature should never be able to crash a critical one.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Monitoring, Health Checks, and Testing Failover
&lt;/h3&gt;

&lt;p&gt;Failover you haven't tested is failover you don't have.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Health checks&lt;/strong&gt; that check real readiness (can it reach the DB?), not just "is the process alive"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Alerts&lt;/strong&gt; on error rates and latency, not just CPU&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Game days and chaos testing:&lt;/strong&gt; deliberately kill a node, an AZ, or a dependency in a controlled way and watch what happens. Netflix's Chaos Monkey made this famous for a reason.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to Hunt for SPOFs: A 5-Step Method
&lt;/h2&gt;

&lt;p&gt;Use this on any system you own, or any design you're whiteboarding.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Trace a critical request end to end.&lt;/strong&gt; Start from the user's device: DNS → CDN → load balancer → app → cache → DB → queues → third-party calls. Write down every hop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask "what if this disappears?" for each hop.&lt;/strong&gt; If the answer is "the request fails and there's no alternative," mark it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check for shared failure domains.&lt;/strong&gt; Two replicas in the same AZ? Same config source? Same deploy? Same vendor? Mark those too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rank by impact × likelihood.&lt;/strong&gt; A SPOF in checkout matters more than one in an internal admin page. Fix the highest-risk ones first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify with a test.&lt;/strong&gt; Kill the component in staging (or production, carefully). Measure how long recovery takes and whether anyone noticed.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Common Mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;"We have a load balancer, so we're redundant."&lt;/strong&gt; Not if there's only one load balancer, or one database behind it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replicas without failover.&lt;/strong&gt; A replica that needs a human to promote it at 3 a.m. gives you minutes to hours of downtime, not seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redundancy without spare capacity.&lt;/strong&gt; If the survivors can't absorb the load, a single failure turns into a cascade.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Same failure domain.&lt;/strong&gt; Two copies in one AZ, or two services reading the same config, fail together.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never testing failover.&lt;/strong&gt; Backups and standbys that have never been exercised often fail exactly when you need them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Over-engineering.&lt;/strong&gt; Not everything needs multi-region active-active. Match the investment to the business cost of downtime.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  SPOFs in the System Design Interview
&lt;/h2&gt;

&lt;p&gt;Interviewers love SPOF questions because they separate candidates who memorized a diagram from those who understand trade-offs. After you sketch your high-level design, take 60 seconds to do this out loud:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Let me walk through the failure points. The load balancer is managed and multi-AZ. App servers are stateless, so we can lose any of them. The database is the main risk, so I'll use a primary with a synchronous replica in another AZ and automatic failover. The trade-off is slightly higher write latency, which is fine for this use case. For the cache, if Redis goes down, we fall back to the DB with rate limiting so we don't overload it."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That one paragraph shows the interviewer you understand redundancy, failover, failure domains, consistency trade-offs, and graceful degradation. It's often the difference between a "hire" at L4 and a strong signal at L5.&lt;/p&gt;

&lt;p&gt;If you want to practice this kind of reasoning on real problems (URL shorteners, chat systems, news feeds, and more), here are a few resources from &lt;a href="https://www.designgurus.io" rel="noopener noreferrer"&gt;Design Gurus&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals" rel="noopener noreferrer"&gt;Grokking System Design Fundamentals&lt;/a&gt;&lt;/strong&gt;: covers the building blocks behind this post, including redundancy, replication, load balancing, and availability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt;&lt;/strong&gt;: walks through classic interview problems end to end, including how to identify and remove bottlenecks and SPOFs in each design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-the-advanced-system-design-interview" rel="noopener noreferrer"&gt;Grokking the Advanced System Design Interview&lt;/a&gt;&lt;/strong&gt;: goes deep into how real distributed systems like Dynamo, Kafka, and Chubby handle replication, quorums, and failover.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A SPOF is any component whose failure alone takes the system down. Your availability is only as strong as your weakest layer.&lt;/li&gt;
&lt;li&gt;Components in series &lt;strong&gt;multiply&lt;/strong&gt; availability downward; redundant components in parallel &lt;strong&gt;compound&lt;/strong&gt; it upward, &lt;em&gt;if&lt;/em&gt; they fail independently.&lt;/li&gt;
&lt;li&gt;The worst SPOFs are often hidden: DNS, config pushes, a single region, shared platform services, third-party APIs, and people.&lt;/li&gt;
&lt;li&gt;Fix SPOFs with redundancy + spare capacity, automated failover, replication, separate failure domains, safe rollouts, and graceful degradation.&lt;/li&gt;
&lt;li&gt;Test your failover regularly. Untested redundancy is just hope.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next time you look at an architecture diagram, ask one question about every box: &lt;strong&gt;"What happens if this one disappears?"&lt;/strong&gt; That habit alone will make your systems, and your interview answers, a lot more resilient.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>architecture</category>
      <category>distributedsystems</category>
      <category>interview</category>
    </item>
    <item>
      <title>How I Learned System Design in the AI Era</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Tue, 17 Nov 2026 00:16:05 +0000</pubDate>
      <link>https://dev.to/arslan_ah/how-i-learned-system-design-in-the-ai-era-10eg</link>
      <guid>https://dev.to/arslan_ah/how-i-learned-system-design-in-the-ai-era-10eg</guid>
      <description>&lt;p&gt;I learned system design the slow way.&lt;/p&gt;

&lt;p&gt;Thick books. Long engineering blogs. Whiteboard sessions where I drew boxes and arrows and hoped they made sense. It worked, eventually. But it took far longer than it should have, mostly because I spent most of that time &lt;em&gt;reading&lt;/em&gt; about systems instead of &lt;em&gt;designing&lt;/em&gt; them.&lt;/p&gt;

&lt;p&gt;Over the last year I've had to learn a lot of new material: vector databases, LLM serving, RAG pipelines, agent architectures. This time I did it differently. I used AI.&lt;/p&gt;

&lt;p&gt;Not to do the learning for me. To make the learning faster.&lt;/p&gt;

&lt;p&gt;Here's the exact approach, and the one rule that makes it work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fasjnq4p4w2woujnsbpvs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fasjnq4p4w2woujnsbpvs.png" alt="The Old Way vs. The AI-Era Way" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📚 &lt;strong&gt;Related:&lt;/strong&gt; &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-in-2027-the-best-resources-in-the-order-you-should-use-them-1i94"&gt;How to Learn System Design in 2027: The Best Resources, in the Order You Should Use Them&lt;/a&gt;, a stage-by-stage path with 20 resources and a 10-week plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem With How Most People Learn System Design
&lt;/h2&gt;

&lt;p&gt;Most engineers learn system design passively.&lt;/p&gt;

&lt;p&gt;They read about consistent hashing. They watch a video on Kafka. They study a reference design of Twitter. Then they walk into an interview, the interviewer says "design a ride-sharing app," and their mind goes blank.&lt;/p&gt;

&lt;p&gt;Why? Because &lt;strong&gt;recognizing&lt;/strong&gt; a good design and &lt;strong&gt;producing&lt;/strong&gt; one are two different skills.&lt;/p&gt;

&lt;p&gt;Reading builds recognition. Only practice builds production.&lt;/p&gt;

&lt;p&gt;The old problem was that practice was expensive. You needed a senior engineer to review your design, or a friend willing to play interviewer. Most people had neither, so they kept reading.&lt;/p&gt;

&lt;p&gt;That bottleneck is gone now.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI Didn't Make System Design Easier. It Made Practice Cheaper.
&lt;/h2&gt;

&lt;p&gt;This is the key shift.&lt;/p&gt;

&lt;p&gt;An AI model can't give you judgment. But it can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Explain a concept five different ways until one clicks&lt;/li&gt;
&lt;li&gt;Quiz you on what you just read&lt;/li&gt;
&lt;li&gt;Poke holes in your design at 11 PM on a Tuesday&lt;/li&gt;
&lt;li&gt;Play a demanding interviewer who keeps asking "why?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Used correctly, that turns every evening into a practice session.&lt;/p&gt;

&lt;p&gt;Used incorrectly, it turns you into someone who can paste a prompt but can't hold a design in their head.&lt;/p&gt;

&lt;p&gt;The difference comes down to &lt;em&gt;when&lt;/em&gt; you let AI into the loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  My AI-Assisted Learning Loop
&lt;/h2&gt;

&lt;p&gt;Every building block I learned went through the same five steps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Facoz2r26qsflgrq1sb0w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Facoz2r26qsflgrq1sb0w.png" alt="My AI-Assisted Learning Loop" width="800" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Learn one building block
&lt;/h3&gt;

&lt;p&gt;Pick one concept. Just one. Caching, sharding, message queues, rate limiting.&lt;/p&gt;

&lt;p&gt;Read a solid source on it. Don't try to cover ten topics in a night.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Explain it back to AI
&lt;/h3&gt;

&lt;p&gt;This is the Feynman technique with a tireless partner. Close the tab and explain the concept in your own words. Then ask AI to find the gaps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I just learned about database sharding. Here's my explanation:

[your explanation]

Don't rewrite it. Tell me:
1. What I got wrong
2. What important detail I left out
3. One follow-up question an interviewer would ask
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the instruction: &lt;strong&gt;don't rewrite it.&lt;/strong&gt; You want feedback, not a better answer you'll forget in an hour.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Design something real (no AI yet)
&lt;/h3&gt;

&lt;p&gt;This is the step most people skip, and it's the only one that matters.&lt;/p&gt;

&lt;p&gt;Take a real problem: "Design a URL shortener." Get a piece of paper. Write the requirements. Draw the components. Pick a database. Decide where the cache goes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do not open the AI chat for this step.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It will feel slow and uncomfortable. That discomfort is the learning.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Ask AI to attack your design
&lt;/h3&gt;

&lt;p&gt;Now bring AI back, but as a critic, not a co-author.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Here is my design for a URL shortener:

[components, data flow, database choice, caching strategy]

Act as a senior engineer reviewing this design.
- Find single points of failure
- Find the bottleneck at 100x traffic
- Point out any trade-off I didn't justify

Ask me questions instead of giving me fixes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "ask me questions" part is important. It forces you to reason through the fix yourself.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Do the numbers
&lt;/h3&gt;

&lt;p&gt;Back-of-the-envelope estimation is where many candidates fall apart. So I do the math first, by hand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Requests per second&lt;/li&gt;
&lt;li&gt;Storage per year&lt;/li&gt;
&lt;li&gt;Bandwidth&lt;/li&gt;
&lt;li&gt;Cache size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then I ask AI to check my arithmetic and my assumptions. Not to do the math.&lt;/p&gt;

&lt;p&gt;Then repeat with the next building block.&lt;/p&gt;

&lt;h2&gt;
  
  
  The One Rule: Never Let AI Design First
&lt;/h2&gt;

&lt;p&gt;If you remember one thing from this post, make it this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If AI gives you the answer before you've struggled with the problem, you learn nothing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's like watching someone else do push-ups. You understand push-ups perfectly. Your arms are exactly as strong as before.&lt;/p&gt;

&lt;p&gt;The struggle in step 3 is not a bug in the process. It &lt;em&gt;is&lt;/em&gt; the process. AI is there to shorten steps 2 and 4, not to remove step 3.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where AI Helps (and Where It Doesn't)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq1189aprp10ipx260pq6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq1189aprp10ipx260pq6.png" alt="Where AI Helps vs. Where You Still Have to Think" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI is great at explaining, spotting obvious gaps, and asking follow-up questions.&lt;/p&gt;

&lt;p&gt;But there are things it can't do for you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Choosing trade-offs for your constraints.&lt;/strong&gt; "Use Cassandra" isn't an answer. "Use Cassandra because we're write-heavy and can tolerate eventual consistency on likes" is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Knowing which requirement matters most.&lt;/strong&gt; Real design is about priorities, and priorities come from context.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Catching AI when it's confidently wrong.&lt;/strong&gt; It will sometimes give you a beautiful, well-formatted, incorrect answer. You need enough fundamentals to notice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Defending your design live.&lt;/strong&gt; In the interview room, there's no AI. Everything has to be in your head.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point is why the loop matters. AI is the training partner. You still have to lift the weight.&lt;/p&gt;

&lt;h2&gt;
  
  
  My 6-Week Roadmap
&lt;/h2&gt;

&lt;p&gt;If I were starting from zero today, this is the order I'd follow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvjj93llgro0fxobvqknq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvjj93llgro0fxobvqknq.png" alt="My 6-Week AI-Era Roadmap" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Weeks 1–2: Foundations.&lt;/strong&gt; Latency vs. throughput, load balancing, caching, CAP theorem, consistency models. These show up in every single design.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 3: Data.&lt;/strong&gt; SQL vs. NoSQL, indexes, replication, sharding. Most bottlenecks in real systems live here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 4: Async and scale.&lt;/strong&gt; Message queues, event-driven architecture, rate limiting, CDNs. This is where systems go from "works" to "works at scale."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 5: Classic designs.&lt;/strong&gt; URL shortener, news feed, chat system, video streaming. Each one combines the building blocks from weeks 1–4 in a new way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 6: Mock interviews.&lt;/strong&gt; Run an AI mock interview most nights. Do at least one mock with a real human each week, because a person will push back in ways AI won't.&lt;/p&gt;

&lt;p&gt;Every topic goes through the same loop: &lt;strong&gt;Learn → Explain → Design → Critique → Estimate.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Using AI as a Mock Interviewer
&lt;/h2&gt;

&lt;p&gt;This was the single biggest unlock for me. Here's the prompt I use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are a senior engineer conducting a 45-minute system design interview.
The problem: Design a notification service for 50M daily users.

Rules:
- Don't give me hints unless I ask
- Ask clarifying-question follow-ups like a real interviewer
- Push back when I make a choice without justifying it
- At the end, score me on: requirements, high-level design,
  deep dives, trade-offs, and communication
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then talk through it out loud, as if a real person were listening. Typing your answers is a different skill from saying them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes I See
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Asking AI to "design Twitter."&lt;/strong&gt; You'll get a perfect-looking answer and learn nothing. Ask it to review &lt;em&gt;your&lt;/em&gt; Twitter design instead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Skipping fundamentals because "AI knows it."&lt;/strong&gt; AI knows it. You don't. And you're the one in the interview.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trusting every answer.&lt;/strong&gt; Cross-check anything surprising against a solid source. Models do make things up, especially numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Binge learning.&lt;/strong&gt; One loop a day beats a 10-hour weekend session. Spaced practice sticks. Cramming doesn't.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;System design hasn't changed much in the AI era. Caching, sharding, queues, and trade-offs work the same way they did ten years ago.&lt;/p&gt;

&lt;p&gt;What changed is how fast you can practice.&lt;/p&gt;

&lt;p&gt;Use AI as a sparring partner, not a ghostwriter. Struggle first, then get feedback. Do that every day for six weeks and you'll be surprised how much clicks.&lt;/p&gt;

&lt;p&gt;If you want a structured path through the fundamentals and classic designs, that's exactly what we built &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt; for. And if you're preparing for the newer AI-focused rounds, check out &lt;a href="https://www.designgurus.io" rel="noopener noreferrer"&gt;Grokking the AI System Design Interview&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;How are you using AI to learn system design? I'd love to hear what's working for you in the comments.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>ai</category>
      <category>career</category>
      <category>programming</category>
    </item>
    <item>
      <title>The 2027 System Design Interview Playbook: Framework, Concepts, and a Full Worked Example</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Mon, 02 Nov 2026 13:38:14 +0000</pubDate>
      <link>https://dev.to/arslan_ah/the-2027-system-design-interview-playbook-framework-concepts-and-a-full-worked-example-2mn6</link>
      <guid>https://dev.to/arslan_ah/the-2027-system-design-interview-playbook-framework-concepts-and-a-full-worked-example-2mn6</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A quick note before we start:&lt;/strong&gt; This guide is written by me, Arslan Ahmad. I'm the founder of &lt;a href="https://www.designgurus.io" rel="noopener noreferrer"&gt;DesignGurus.io&lt;/a&gt; and the author of &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt;. Before that, I spent years as a software engineer and hiring manager at Microsoft and Meta, where I sat on the other side of hundreds of these interviews. Where one of our courses or articles goes deeper on a topic, I link it. You can follow everything in this playbook without buying anything.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you're preparing for a system design interview in 2027, you're facing a strange situation. There's more free material than ever, and it has never been harder to know what to study.&lt;/p&gt;

&lt;p&gt;Most guides give you one of three things: a list of concepts with no idea how to use them, a framework with no worked example, or a single example with no reusable method. Candidates come out of those guides knowing what a load balancer is but freezing when an interviewer says "Design Instagram's feed. You have 45 minutes."&lt;/p&gt;

&lt;p&gt;This playbook gives you all three in one place:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A framework&lt;/strong&gt; you can apply to any question, with a minute-by-minute time budget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The core concepts&lt;/strong&gt; that show up in nearly every interview, explained at the depth interviewers actually probe.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A full worked example&lt;/strong&gt; (a news feed), done the way I'd want a strong senior candidate to do it, with real numbers, a data model, deep dives, and failure handling.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's long on purpose. Bookmark it, skim the table of contents, and come back to the sections you need.&lt;/p&gt;

&lt;p&gt;📚 &lt;strong&gt;Related:&lt;/strong&gt; &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-in-2027-the-best-resources-in-the-order-you-should-use-them-1i94"&gt;How to Learn System Design in 2027: The Best Resources, in the Order You Should Use Them&lt;/a&gt;, a stage-by-stage path with 20 resources and a 10-week plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR: The 60-Second Version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The interview tests how you think, not what you've memorized.&lt;/strong&gt; There's no single correct answer. There are defensible trade-offs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use a framework every time:&lt;/strong&gt; clarify requirements → estimate scale → define the API → model the data → high-level design → deep dives → bottlenecks and wrap-up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Spend the first ~15 minutes on scope, numbers, API, and data.&lt;/strong&gt; Candidates who skip this end up designing the wrong system very well.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Know ~15 building blocks cold:&lt;/strong&gt; load balancers, caches, CDNs, SQL vs NoSQL, replication, sharding, consistent hashing, queues, rate limiting, idempotency, IDs, CAP/PACELC, consistency models, observability, API styles.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Every decision should come with a "because."&lt;/strong&gt; "I'll use Cassandra &lt;em&gt;because&lt;/em&gt; the workload is write-heavy, access is by key, and we can tolerate eventual consistency."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Seniority is judged by how you drive the conversation&lt;/strong&gt;, not by how many boxes you draw.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2027 additions:&lt;/strong&gt; expect AI/LLM system questions, more focus on cost and observability, and designing APIs that AI agents (not just humans) will call.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;What Is a System Design Interview?&lt;/li&gt;
&lt;li&gt;What's Different About System Design Interviews in 2027&lt;/li&gt;
&lt;li&gt;The Types of System Design Interviews&lt;/li&gt;
&lt;li&gt;How You're Evaluated (and What Changes by Level)&lt;/li&gt;
&lt;li&gt;The 7-Step System Design Interview Framework&lt;/li&gt;
&lt;li&gt;Core Concepts: The System Design Toolkit&lt;/li&gt;
&lt;li&gt;The Trade-offs Interviewers Love to Probe&lt;/li&gt;
&lt;li&gt;Full Worked Example: Design a News Feed&lt;/li&gt;
&lt;li&gt;Bonus: A Template for AI System Design Questions&lt;/li&gt;
&lt;li&gt;The Most Common System Design Interview Questions&lt;/li&gt;
&lt;li&gt;12 Mistakes That Sink Strong Candidates&lt;/li&gt;
&lt;li&gt;An 8-Week Preparation Plan&lt;/li&gt;
&lt;li&gt;Best Resources to Prepare&lt;/li&gt;
&lt;li&gt;FAQ&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What Is a System Design Interview?
&lt;/h2&gt;

&lt;p&gt;A system design interview is a 45 to 60 minute conversation where you design a large-scale software system from a vague prompt. "Design a URL shortener." "Design WhatsApp." "Design a rate limiter." "Design a system that lets 10 million people buy concert tickets at the same moment."&lt;/p&gt;

&lt;p&gt;You'll usually work on a whiteboard or a shared online diagramming tool. The interviewer plays a mix of product manager, tech lead, and skeptical colleague. They answer your questions, push on weak spots, and steer you toward the parts they want to see in depth.&lt;/p&gt;

&lt;p&gt;What it is &lt;strong&gt;not&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Not a trivia quiz.&lt;/strong&gt; Nobody will ask you to recite the Raft paper. They'll ask you &lt;em&gt;why&lt;/em&gt; you need consensus here and what happens if the leader dies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not a test of whether you've built this exact system.&lt;/strong&gt; Very few candidates have built Twitter. Interviewers know that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not a search for the "right" architecture.&lt;/strong&gt; Two candidates can draw very different diagrams and both get a strong hire. What matters is whether your choices fit the requirements and whether you can defend them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What it &lt;strong&gt;is&lt;/strong&gt;: a simulation of a design review. The question behind every question is, &lt;em&gt;"Would I trust this person to lead the design of a real system on my team?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's why the system design round carries so much weight in leveling decisions. A coding round tells a company whether you can write correct code. A system design round tells them whether you're a mid-level, senior, or staff engineer. If you want the long version of how this round fits into the loop, I wrote about it in &lt;a href="https://www.designgurus.io/blog/system-design-interview-fundamentals" rel="noopener noreferrer"&gt;System Design Interview Fundamentals&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Different About System Design Interviews in 2027
&lt;/h2&gt;

&lt;p&gt;The core of the interview hasn't changed in a decade: requirements, scale, components, trade-offs. But the questions and the bar around them have shifted. Here's what I'm seeing from candidates and hiring managers going into 2027.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. AI system design questions are now mainstream.&lt;/strong&gt; "Design ChatGPT," "Design a RAG-based support bot," and "Design an LLM inference service" have moved from niche ML loops into general backend loops. You don't need to be an ML researcher, but you do need to know how retrieval, vector search, model serving, token streaming, and GPU cost fit into an architecture. I added a template for these below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Your API's clients might be agents, not people.&lt;/strong&gt; More systems now have AI agents calling them in tight loops. That raises the stakes on things that used to be "nice to have": idempotency keys, strict rate limits per key, machine-readable errors, pagination that doesn't break under retries, and clear contracts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Cost is a first-class requirement.&lt;/strong&gt; Interviewers increasingly ask, "What does this cost to run?" A design that needs 4,000 GPUs or petabytes of hot Redis isn't automatically wrong, but you should notice and say so.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Observability and failure modes get more airtime.&lt;/strong&gt; "How would you know it's broken?" and "What happens when the cache cluster dies?" are now standard follow-ups, especially at senior levels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Interviewers expect you to drive.&lt;/strong&gt; With so much prep material available, the baseline has gone up. Reciting a memorized "Design Twitter" answer stands out less than it used to. Adapting your design to the interviewer's twist stands out more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Some companies now allow AI tools in parts of the loop.&lt;/strong&gt; Policies vary a lot between companies and change often, so ask your recruiter. Even where AI assistance is allowed, the system design round is still mostly about &lt;em&gt;your&lt;/em&gt; judgment: what to build, what to skip, and why.&lt;/p&gt;

&lt;p&gt;None of this changes the fundamentals. If anything, it rewards them more. You can't reason about LLM serving costs if you can't do back-of-the-envelope math.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Types of System Design Interviews
&lt;/h2&gt;

&lt;p&gt;"System design" covers a few different interview formats. Find out which one you're getting, because the prep is different.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Typical prompt&lt;/th&gt;
&lt;th&gt;What they're really testing&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Product / backend design&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Design Instagram, Uber, Dropbox&lt;/td&gt;
&lt;td&gt;End-to-end architecture, data modeling, scaling&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Infrastructure design&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Design a rate limiter, key-value store, message queue&lt;/td&gt;
&lt;td&gt;Distributed systems depth, consistency, failure handling&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;API design&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Design the API for a payments platform&lt;/td&gt;
&lt;td&gt;Resource modeling, versioning, idempotency, pagination&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Object-oriented / low-level design&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Design a parking lot, elevator system&lt;/td&gt;
&lt;td&gt;Classes, interfaces, design patterns, extensibility&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AI / ML system design&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Design ChatGPT, a recommendation system&lt;/td&gt;
&lt;td&gt;Data pipelines, model serving, evaluation, cost&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Mobile / frontend system design&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Design the Instagram mobile app&lt;/td&gt;
&lt;td&gt;Client architecture, offline sync, caching, rendering&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Most backend and full-stack engineers will see &lt;strong&gt;product design&lt;/strong&gt; and &lt;strong&gt;infrastructure design&lt;/strong&gt;. Meta, for example, has long split its loop into "product architecture" and "system design" flavors. I break down each format in &lt;a href="https://www.designgurus.io/blog/types-of-system-design-interviews" rel="noopener noreferrer"&gt;Types of System Design Interviews: Product, Infrastructure, and More&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This playbook focuses on the product and infrastructure formats, because that's where most people need help. The framework applies to all of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  How You're Evaluated (and What Changes by Level)
&lt;/h2&gt;

&lt;p&gt;Interviewers don't score your diagram. They score signals. Almost every big-tech rubric I've seen boils down to four:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Problem navigation.&lt;/strong&gt; Do you scope the problem before solving it? Do you ask questions that change the design, not questions for the sake of asking?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Solution design.&lt;/strong&gt; Do the components fit together into something that would actually work end to end?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Technical depth.&lt;/strong&gt; When pushed on a component, do you know &lt;em&gt;why&lt;/em&gt; it works, not just &lt;em&gt;what&lt;/em&gt; it is?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Communication.&lt;/strong&gt; Do you think out loud, check in, and adjust when the interviewer gives you a hint?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The same question is asked to mid-level, senior, and staff candidates. What changes is the bar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxmnhkrwf1y0l8qfhgdqa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxmnhkrwf1y0l8qfhgdqa.png" alt="What system design interviewers evaluate at L4, L5, and L6" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;L4 / mid-level:&lt;/strong&gt; You can produce a working design with reasonable components. The interviewer may guide you through some steps. You discuss a couple of trade-offs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;L5 / senior:&lt;/strong&gt; You drive the whole conversation without prompting. You pick the two or three hardest parts of the problem and go deep. You back decisions with numbers and plan for failure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;L6 / staff:&lt;/strong&gt; You reframe the problem. You compare multiple architectures before committing. You talk about cost, migration paths, operational burden, and what you'd deliberately &lt;em&gt;not&lt;/em&gt; build in v1.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a practical way to tell where you are: record yourself doing a mock interview, then count how many times the interviewer had to redirect you. Senior candidates rarely need it. I wrote about the specific behaviors that separate candidates in &lt;a href="https://www.designgurus.io/blog/sys-design-distinguishes" rel="noopener noreferrer"&gt;7 Tips to Stand Out in Your System Design Interview&lt;/a&gt;, and I list level-appropriate practice questions in &lt;a href="https://dev.to/arslan_ah/system-design-interview-questions-by-level-junior-mid-level-senior-and-staff-2m6h"&gt;System Design Interview Questions by Level&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you have never run a timed mock before, this &lt;a href="https://www.designgurus.io/blog/system-design-mock-interview" rel="noopener noreferrer"&gt;guide to system design mock interviews&lt;/a&gt; breaks down what happens minute by minute, how the scorecard works, and which platforms to practice on.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 7-Step System Design Interview Framework
&lt;/h2&gt;

&lt;p&gt;This is the framework I've taught for years in &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt;. It's not magic. It just makes sure you never skip the steps that interviewers grade, and it keeps you from panicking when the prompt is vague.&lt;/p&gt;

&lt;p&gt;For another end-to-end walkthrough of this framework, with the exact signals interviewers score, see &lt;a href="https://arslan-ahmad.medium.com/the-complete-system-design-interview-guide-for-2027-85a1ab94ace7" rel="noopener noreferrer"&gt;The Complete System Design Interview Guide for 2027&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftb2isl26fvp7je7g04b8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftb2isl26fvp7je7g04b8.png" alt="The 7-step system design interview framework with a 45-minute time budget" width="799" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you prefer video, here's my walkthrough of the same 7-step method:&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/N3r-Z6_IGTM" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Let's go through each step: what to do, what to say, and what to avoid.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Clarify Requirements (≈5 minutes)
&lt;/h3&gt;

&lt;p&gt;Every system design prompt is underspecified on purpose. The interviewer wants to see whether you'll charge ahead or figure out what you're building first.&lt;/p&gt;

&lt;p&gt;Split requirements into two lists and write both on the board.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functional requirements&lt;/strong&gt; are what the system does. Aim for 3 to 5 core features, and explicitly park the rest.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"For a news feed, I'm thinking the core features are: users can create posts with text and images, follow other users, and see a feed of posts from people they follow. I'll leave out comments, likes, ads, and search for now unless you'd like me to include them. Does that work?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Non-functional requirements&lt;/strong&gt; are how well it does it. These drive the architecture far more than the features do. Ask about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scale:&lt;/strong&gt; How many users? Daily active users? Read-heavy or write-heavy?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Latency:&lt;/strong&gt; What's acceptable for the critical path? (For a feed: p99 under ~200 ms.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Availability vs consistency:&lt;/strong&gt; Is it OK if a post takes a few seconds to appear for followers? (Usually yes.) Is it OK if a payment is double-charged? (Never.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Durability:&lt;/strong&gt; Can we ever lose data? (Posts: no. View counts: maybe.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other constraints:&lt;/strong&gt; Global or single region? Mobile clients with bad networks? Compliance needs?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Avoid:&lt;/strong&gt; asking 15 questions in a row. Ask the ones whose answers change the design, propose sensible defaults for the rest, and move on.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Back-of-the-Envelope Estimation (≈3–5 minutes)
&lt;/h3&gt;

&lt;p&gt;Estimation turns "it should scale" into "we need roughly this much." Its job is to tell you which parts of the system are hard. A design serving 100 QPS and a design serving 1 million QPS look very different.&lt;/p&gt;

&lt;p&gt;Estimate four things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Traffic:&lt;/strong&gt; reads and writes per second, average and peak.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage:&lt;/strong&gt; per day, per year, and total.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bandwidth:&lt;/strong&gt; bytes in and out per second, mostly relevant for media.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory:&lt;/strong&gt; what you'd need to cache the hot set.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The trick is to round aggressively. A day has 86,400 seconds; call it 100,000 (10⁵). So 1 million requests/day ≈ 10 per second, and 1 billion/day ≈ 10,000 per second. Interviewers want the order of magnitude and your reasoning, not decimals.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7ybi2lra1qnv4iye7qpx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7ybi2lra1qnv4iye7qpx.png" alt="Back-of-the-envelope estimation cheat sheet: latency numbers, traffic math, availability nines, and typical sizes" width="800" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Avoid:&lt;/strong&gt; spending 10 minutes on math the design doesn't use. Every number you compute should lead to a decision ("~35K peak read QPS, so we need a cache in front of the database").&lt;/p&gt;

&lt;p&gt;For a step-by-step method with practice problems, read &lt;a href="https://www.designgurus.io/blog/back-of-the-envelope-system-design-interview" rel="noopener noreferrer"&gt;Back-of-the-Envelope Estimation for System Design Interviews&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Define the API (≈3–5 minutes)
&lt;/h3&gt;

&lt;p&gt;The API is the contract between your system and the world. Writing it down forces you and the interviewer to agree on exactly what the system does.&lt;/p&gt;

&lt;p&gt;Keep it to the 3 to 5 endpoints that match your functional requirements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;posts&lt;/span&gt;              &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;media_ids&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idempotency_key&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;post_id&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="na"&gt;GET  /v1/feed?cursor&lt;/span&gt;&lt;span class="o"&gt;=&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;                                       &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;next_cursor&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;follow&lt;/span&gt;                                           &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;204&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Things worth mentioning briefly, because they show maturity:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pagination:&lt;/strong&gt; cursor-based, not offset-based, for anything that changes in real time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Idempotency keys&lt;/strong&gt; on writes, so a retried request doesn't create a duplicate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auth and rate limiting&lt;/strong&gt; at the gateway.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API style:&lt;/strong&gt; REST is the default for public APIs, gRPC is common between internal services, and GraphQL fits client-driven aggregation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 4: Model the Data (≈3–5 minutes)
&lt;/h3&gt;

&lt;p&gt;List the core entities, their key fields, and, most importantly, &lt;strong&gt;the access patterns&lt;/strong&gt;. Your database choice should follow from how data is read and written, not from what's fashionable.&lt;/p&gt;

&lt;p&gt;Questions to answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What are the main entities and relationships?&lt;/li&gt;
&lt;li&gt;What are the top 2–3 queries? (e.g., "get the latest 20 posts for user X's feed")&lt;/li&gt;
&lt;li&gt;Do we need transactions across entities, or mostly single-key reads and writes?&lt;/li&gt;
&lt;li&gt;How will this be partitioned once it no longer fits on one machine?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good habit: say out loud which database you'd pick &lt;strong&gt;and why&lt;/strong&gt;, in one sentence. "Follows are a simple many-to-many relationship queried by user ID in both directions. A sharded relational store with two tables, one keyed by follower and one by followee, handles that well."&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: High-Level Design (≈8–10 minutes)
&lt;/h3&gt;

&lt;p&gt;Now draw the boxes. Start with the simplest design that satisfies the functional requirements end to end, then evolve it to meet the non-functional ones.&lt;/p&gt;

&lt;p&gt;A reliable approach:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Draw the client, the entry point (load balancer / API gateway), and the services that handle each API.&lt;/li&gt;
&lt;li&gt;Add the data stores from Step 4.&lt;/li&gt;
&lt;li&gt;Walk through &lt;strong&gt;one write request&lt;/strong&gt; and &lt;strong&gt;one read request&lt;/strong&gt; end to end, out loud.&lt;/li&gt;
&lt;li&gt;Add caches, queues, CDNs, and replicas only where your numbers from Step 2 say you need them.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Avoid:&lt;/strong&gt; drawing 25 boxes before explaining any of them. Five well-explained boxes beat twenty-five vague ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Deep Dives (≈10–12 minutes)
&lt;/h3&gt;

&lt;p&gt;This is where most hiring decisions are made. Pick the two or three components that are hardest &lt;em&gt;for this specific problem&lt;/em&gt; and go deep. Often the interviewer will steer you; at senior levels, they want to see you pick.&lt;/p&gt;

&lt;p&gt;How to find the hard parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where does the scale from Step 2 concentrate? (A hot key? A huge fan-out?)&lt;/li&gt;
&lt;li&gt;Where do consistency requirements bite? (Payments, inventory, bookings.)&lt;/li&gt;
&lt;li&gt;What's unique to this problem? (Geospatial search for Uber, fan-out for feeds, contention for ticketing.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For each deep dive, present &lt;strong&gt;two or three options, compare them, then commit&lt;/strong&gt;. That pattern alone separates many senior candidates from mid-level ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Bottlenecks, Failures, and Wrap-up (≈5 minutes)
&lt;/h3&gt;

&lt;p&gt;Finish by stress-testing your own design:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Single points of failure:&lt;/strong&gt; what happens if each box dies?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bottlenecks:&lt;/strong&gt; which component saturates first as traffic grows 10×?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hot spots:&lt;/strong&gt; celebrity users, viral content, popular keys.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Observability:&lt;/strong&gt; what would you monitor and alert on?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What's next:&lt;/strong&gt; what would you add with more time?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzewlje4aas4haxhv65l7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzewlje4aas4haxhv65l7.png" alt="How bottlenecks limit system throughput: a 2,000 RPS database caps the whole pipeline" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That last image captures the key point: a system is only as fast as its slowest stage. Scaling your app servers from 8,000 to 80,000 RPS does nothing if the database tops out at 2,000.&lt;/p&gt;

&lt;p&gt;Want the full step-by-step breakdown with examples for each step? See &lt;a href="https://www.designgurus.io/blog/step-by-step-guide" rel="noopener noreferrer"&gt;System Design Interview Guide – 7 Steps to Ace It&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Concepts: The System Design Toolkit
&lt;/h2&gt;

&lt;p&gt;You don't need to know everything about distributed systems. You need a toolkit of roughly 15 concepts that you understand well enough to (a) know when to use each one and (b) answer two levels of "why?" about it.&lt;/p&gt;

&lt;p&gt;Here's how they fit together in a typical web system:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl4e5i4gyrehupn52qp54.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl4e5i4gyrehupn52qp54.png" alt="Anatomy of a scalable web system: clients, CDN, load balancer, API gateway, app services, cache, databases, queue, and workers" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Scalability: Vertical vs Horizontal
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Vertical scaling&lt;/strong&gt; (scale up) means a bigger machine. It's simple and there are no distributed-system headaches, but there's a ceiling and a single point of failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Horizontal scaling&lt;/strong&gt; (scale out) means more machines. There's effectively no ceiling, but now you need load balancing, data partitioning, and a plan for partial failure.&lt;/p&gt;

&lt;p&gt;The interview move: keep your application servers &lt;strong&gt;stateless&lt;/strong&gt; (sessions in a shared store like Redis, files in object storage) so you can scale them horizontally behind a load balancer. Then focus your energy on the stateful parts, which are almost always the hard parts.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Load Balancing
&lt;/h3&gt;

&lt;p&gt;A load balancer spreads requests across servers and routes around unhealthy ones.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;L4 (transport layer)&lt;/strong&gt; balances TCP/UDP connections. It's fast and doesn't look at content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;L7 (application layer)&lt;/strong&gt; looks at HTTP paths, headers, and cookies, so it can route &lt;code&gt;/api/video&lt;/code&gt; differently from &lt;code&gt;/api/chat&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Algorithms:&lt;/strong&gt; round robin, least connections, weighted, and consistent hashing (when you want the same user or key to hit the same server, e.g., for local caches).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mention &lt;strong&gt;health checks&lt;/strong&gt;, and that the load balancer itself must be redundant (active-passive pairs or a managed cloud LB), or it becomes your single point of failure.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Caching
&lt;/h3&gt;

&lt;p&gt;Caching is the highest-leverage tool in system design. Reading from memory is roughly 1,000× faster than a disk-backed database query. A good cache can absorb 90%+ of read traffic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffz4rl31p7in0nhgj12kc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffz4rl31p7in0nhgj12kc.png" alt="Caching strategies: cache-aside, write-through, and write-back compared" width="799" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Know where caches live (client, CDN, application-level like Redis, database buffer cache) and the main write policies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cache-aside&lt;/strong&gt; (lazy loading): the default. App checks cache, falls back to DB on a miss, then populates the cache.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write-through:&lt;/strong&gt; writes go through the cache to the DB, so the cache is never stale for written keys.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write-back:&lt;/strong&gt; writes go only to the cache and are flushed later. Fastest, but you can lose data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then be ready for the follow-ups: How do you invalidate? (TTL plus explicit delete on write.) What's the eviction policy? (Usually LRU.) What happens when a hot key expires and 10,000 requests hit the database at once? (A cache stampede; fix it with request coalescing, jittered TTLs, or proactive refresh.)&lt;/p&gt;

&lt;p&gt;Redis comes up in almost every interview, so know its data structures, not just "key → value." Sorted sets (leaderboards, feeds), hashes (objects), and streams (event logs) solve a lot of design problems on their own.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyeza7okg1pgniu7ssglk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyeza7okg1pgniu7ssglk.png" alt="Redis in-memory data structures: strings, lists, sets, sorted sets, hashes, and streams" width="800" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Content Delivery Networks (CDNs)
&lt;/h3&gt;

&lt;p&gt;A CDN caches static content (images, video, JS, CSS) at edge locations close to users. It cuts latency for global users and offloads huge amounts of bandwidth from your origin.&lt;/p&gt;

&lt;p&gt;Use a CDN for anything large and read-heavy: profile pictures, video segments, thumbnails. Mention &lt;strong&gt;cache keys and versioned URLs&lt;/strong&gt; (e.g., &lt;code&gt;avatar_v3.jpg&lt;/code&gt;) so updates don't serve stale content. A cross-continent round trip is ~150 ms, while a CDN edge is often a few milliseconds away.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Databases: SQL vs NoSQL
&lt;/h3&gt;

&lt;p&gt;This is one of the most-asked trade-offs. Don't answer with "NoSQL scales better." Answer with access patterns.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Relational (PostgreSQL, MySQL)&lt;/th&gt;
&lt;th&gt;NoSQL (Cassandra, DynamoDB, MongoDB)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Schema&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fixed, enforced&lt;/td&gt;
&lt;td&gt;Flexible&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Transactions&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Full ACID across rows and tables&lt;/td&gt;
&lt;td&gt;Usually single-item or limited&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Queries&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Joins, ad-hoc queries&lt;/td&gt;
&lt;td&gt;Optimized for known access patterns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scaling writes&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Harder; needs manual sharding&lt;/td&gt;
&lt;td&gt;Built-in partitioning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best for&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Payments, orders, inventory, anything relational&lt;/td&gt;
&lt;td&gt;High-volume key-based access, time series, feeds&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A strong answer sounds like: "Orders need multi-row transactions and strong consistency, so PostgreSQL. The activity log is append-heavy, read by user ID and time range, and can be eventually consistent, so Cassandra."&lt;/p&gt;

&lt;p&gt;Also know the specialized stores: &lt;strong&gt;object storage&lt;/strong&gt; (S3) for blobs, &lt;strong&gt;search indexes&lt;/strong&gt; (Elasticsearch/OpenSearch) for full-text search, &lt;strong&gt;time-series databases&lt;/strong&gt; for metrics, &lt;strong&gt;graph databases&lt;/strong&gt; for deep relationship queries, and &lt;strong&gt;vector databases&lt;/strong&gt; for embeddings in AI systems.&lt;/p&gt;

&lt;p&gt;For the deeper comparison, see &lt;a href="https://www.designgurus.io/blog/sql-vs-nosql-key-differences" rel="noopener noreferrer"&gt;SQL vs. NoSQL: Key Differences&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Indexing
&lt;/h3&gt;

&lt;p&gt;An index makes reads fast at the cost of slower writes and extra storage. B-tree indexes handle range queries; hash indexes handle exact matches. LSM-tree storage engines (Cassandra, RocksDB) make writes cheap by appending and compacting later.&lt;/p&gt;

&lt;p&gt;The interview-relevant point: &lt;strong&gt;design your indexes around your queries.&lt;/strong&gt; If your top query is "posts by user, newest first," you want a composite index (or a partition + clustering key) on &lt;code&gt;(author_id, created_at DESC)&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Replication
&lt;/h3&gt;

&lt;p&gt;Replication keeps copies of data on multiple machines for availability, durability, and read scaling.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Leader–follower (primary–replica):&lt;/strong&gt; one node takes writes, replicas serve reads. Simple, but replicas can lag (stale reads), and failover needs care.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-leader:&lt;/strong&gt; multiple nodes accept writes (e.g., one per region). Good for geo-distribution, but you have to resolve write conflicts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leaderless (Dynamo-style):&lt;/strong&gt; any replica accepts writes; reads and writes use quorums (e.g., with N=3, W=2, R=2, so R + W &amp;gt; N guarantees overlap).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Know &lt;strong&gt;synchronous vs asynchronous&lt;/strong&gt; replication: synchronous is safer but slower; asynchronous is faster but can lose the latest writes on failover.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Sharding (Partitioning) and Consistent Hashing
&lt;/h3&gt;

&lt;p&gt;When data or write traffic outgrows one machine, you split it across many. The hard part is picking the &lt;strong&gt;shard key&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpejqcaxpcry2wy48f7t5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpejqcaxpcry2wy48f7t5.png" alt="Database sharding with consistent hashing, virtual nodes, and shard key selection" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Range-based:&lt;/strong&gt; easy range scans, but risk of hot spots (all new data hits the last shard).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hash-based:&lt;/strong&gt; even distribution, but range queries become scatter-gather.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Directory-based:&lt;/strong&gt; a lookup service maps keys to shards. Flexible, but it's another component to keep available.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Consistent hashing&lt;/strong&gt; solves the "add a server and everything moves" problem. With &lt;code&gt;hash(key) % N&lt;/code&gt;, going from 4 to 5 servers remaps about 80% of keys. On a hash ring, only about 1/N of keys move. Virtual nodes smooth out the distribution further. This shows up in caches, Dynamo-style databases, and load balancers. If you want a dedicated walkthrough, I wrote &lt;a href="https://dev.to/arslan_ah/how-to-use-consistent-hashing-in-a-system-design-interview-33ge"&gt;How to Use Consistent Hashing in a System Design Interview&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Always mention &lt;strong&gt;hot keys&lt;/strong&gt;: a celebrity's user ID or a viral post can overload one shard no matter how good your hash function is.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. CAP and PACELC
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;CAP:&lt;/strong&gt; when a network partition happens, a distributed system must choose between &lt;strong&gt;consistency&lt;/strong&gt; (every read sees the latest write, or gets an error) and &lt;strong&gt;availability&lt;/strong&gt; (every request gets a response, possibly stale). You can't skip partitions in a real network, so "CA" isn't a real option for a distributed system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PACELC&lt;/strong&gt; extends this: &lt;strong&gt;if&lt;/strong&gt; there's a Partition, choose Availability or Consistency; &lt;strong&gt;else&lt;/strong&gt; (normal operation), choose Latency or Consistency. This is the more useful framing, because your system spends most of its time &lt;em&gt;not&lt;/em&gt; partitioned.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fot462qkuuahac36e4n3q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fot462qkuuahac36e4n3q.png" alt="CAP theorem and PACELC trade-offs explained for system design interviews" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The senior move is to choose &lt;strong&gt;per feature, not per system&lt;/strong&gt;. A social app's feed can be AP/EL; the payments for promoted posts in the same app must be CP/EC.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Consistency Models
&lt;/h3&gt;

&lt;p&gt;Between "strong" and "eventual" there's a useful middle ground, and naming it precisely is a strong signal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Strong (linearizable):&lt;/strong&gt; every read sees the latest write. Expensive, especially across regions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Eventual:&lt;/strong&gt; replicas converge if writes stop. Cheap and highly available.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read-your-writes:&lt;/strong&gt; a user always sees their own updates (e.g., your own post shows up in your feed immediately), even if others see it a moment later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monotonic reads:&lt;/strong&gt; a user never sees data go "back in time" between requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Causal:&lt;/strong&gt; if A caused B (a reply to a comment), everyone sees A before B.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Read-your-writes is the one that saves you in most product designs. Users tolerate others being a few seconds behind; they don't tolerate their own action disappearing. More on this in &lt;a href="https://www.designgurus.io/blog/consistency-patterns-distributed-systems" rel="noopener noreferrer"&gt;Consistency Patterns in Distributed Systems&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  11. Message Queues and Event-Driven Architecture
&lt;/h3&gt;

&lt;p&gt;Queues decouple producers from consumers. A service publishes an event, and any number of consumers process it at their own pace.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq001zkwexfj7d9vobil5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq001zkwexfj7d9vobil5.png" alt="Event-driven architecture: an Order Service publishes an Order Placed event to an event bus consumed by inventory, fulfillment, notification, analytics, and fraud services" width="799" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why they matter in interviews:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Absorb spikes:&lt;/strong&gt; the queue buffers bursts that would otherwise overwhelm downstream services.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Async work:&lt;/strong&gt; send emails, resize images, update search indexes without blocking the user's request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fan-out:&lt;/strong&gt; one "OrderPlaced" event feeds inventory, fulfillment, notifications, analytics, and fraud, as in the diagram above.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Know the difference between a &lt;strong&gt;queue&lt;/strong&gt; (SQS, RabbitMQ: each message is processed by one consumer, then deleted) and a &lt;strong&gt;log/stream&lt;/strong&gt; (Kafka, Kinesis: messages are retained and can be replayed by many consumer groups). Know &lt;strong&gt;delivery semantics&lt;/strong&gt;: at-most-once, at-least-once (the common default), and "effectively once" via idempotent consumers. And know &lt;strong&gt;back pressure&lt;/strong&gt;: what happens when consumers can't keep up.&lt;/p&gt;

&lt;h3&gt;
  
  
  12. Rate Limiting
&lt;/h3&gt;

&lt;p&gt;Rate limiting protects your system from abuse, runaway clients, and (increasingly) runaway AI agents. Common algorithms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Token bucket:&lt;/strong&gt; allows bursts up to the bucket size, then a steady rate. The most common choice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leaky bucket:&lt;/strong&gt; smooths output to a constant rate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fixed window counter:&lt;/strong&gt; simple, but allows bursts at window edges.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sliding window log/counter:&lt;/strong&gt; more accurate, a bit more expensive.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In a distributed setup, counters usually live in Redis with atomic operations (or a Lua script). Rate limiting is also a classic standalone interview question; I walk through it in &lt;a href="https://dev.to/arslan_ah/grokking-the-system-design-interview-how-to-design-a-rate-limiter-step-by-step-5g25"&gt;How to Design a Rate Limiter (Step by Step)&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  13. Idempotency and Retries
&lt;/h3&gt;

&lt;p&gt;Networks fail, clients retry, and at-least-once queues redeliver. Any operation that can be retried must be safe to repeat.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have clients send an &lt;strong&gt;idempotency key&lt;/strong&gt; with each write; the server stores the key and the result, and returns the stored result for repeats.&lt;/li&gt;
&lt;li&gt;Make consumers idempotent (e.g., "set status to SHIPPED" instead of "increment shipped count").&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;exponential backoff with jitter&lt;/strong&gt; on retries, so a recovering service isn't flattened by a synchronized retry storm.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In any design involving money, orders, or bookings, bring this up before the interviewer does.&lt;/p&gt;

&lt;h3&gt;
  
  
  14. Unique ID Generation
&lt;/h3&gt;

&lt;p&gt;Auto-increment IDs don't work across shards. Common options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;UUIDv4:&lt;/strong&gt; no coordination, but 128 bits, random, and not sortable (bad for B-tree index locality).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UUIDv7 / ULID:&lt;/strong&gt; time-ordered, sortable, and no coordination needed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Snowflake-style IDs:&lt;/strong&gt; 64-bit = timestamp + machine ID + sequence. Compact and roughly time-sorted, which makes them perfect as cursors for feeds.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  15. Observability and Reliability
&lt;/h3&gt;

&lt;p&gt;You can't operate what you can't see. Mention:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Metrics:&lt;/strong&gt; the four golden signals (latency, traffic, errors, saturation), plus business metrics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logs and distributed tracing:&lt;/strong&gt; to follow one request across many services.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SLOs:&lt;/strong&gt; e.g., "99.9% of feed requests under 200 ms." Error budgets tell you when to slow down releases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resilience patterns:&lt;/strong&gt; timeouts, retries with backoff, circuit breakers, bulkheads, graceful degradation (serve a stale feed rather than an error page).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are 60+ named patterns in this space. I collected them, with when to use each, in &lt;a href="https://www.designgurus.io/blog/system-design-patterns-complete-guide" rel="noopener noreferrer"&gt;System Design Patterns: The Complete Guide&lt;/a&gt;. For a one-page version of this whole toolkit, there's also the &lt;a href="https://www.designgurus.io/blog/system-design-cheat-sheet" rel="noopener noreferrer"&gt;System Design Cheat Sheet&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Where to learn these properly:&lt;/strong&gt; If several of these concepts are new to you, start with &lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals" rel="noopener noreferrer"&gt;Grokking System Design Fundamentals&lt;/a&gt;. It covers each building block from scratch. If you know the basics but struggle to &lt;em&gt;apply&lt;/em&gt; them under pressure (when to shard, what to cache, how to survive failures), &lt;a href="https://www.designgurus.io/course/grokking-scalable-systems-for-interviews" rel="noopener noreferrer"&gt;Grokking Scalable Systems for Interviews&lt;/a&gt; treats caching, sharding, replication, and fault tolerance as design decisions rather than definitions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Trade-offs Interviewers Love to Probe
&lt;/h2&gt;

&lt;p&gt;System design is the art of choosing what to give up. Here are the trade-offs that come up most often, with a one-line rule of thumb for each.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Trade-off&lt;/th&gt;
&lt;th&gt;Lean toward the first when…&lt;/th&gt;
&lt;th&gt;Lean toward the second when…&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Consistency vs availability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Money, inventory, bookings&lt;/td&gt;
&lt;td&gt;Feeds, likes, view counts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Latency vs throughput&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;User-facing requests&lt;/td&gt;
&lt;td&gt;Batch jobs, analytics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SQL vs NoSQL&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Relationships, transactions&lt;/td&gt;
&lt;td&gt;Massive scale, simple key access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Push vs pull&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Readers far outnumber writers&lt;/td&gt;
&lt;td&gt;Writers with huge audiences&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Sync vs async&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The user needs the result now&lt;/td&gt;
&lt;td&gt;The work can happen later&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cache-aside vs write-through&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Read-heavy, staleness OK&lt;/td&gt;
&lt;td&gt;Must read your own writes from cache&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Monolith vs microservices&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Small team, early product&lt;/td&gt;
&lt;td&gt;Many teams, independent scaling&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Strong vs eventual consistency&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Correctness is critical&lt;/td&gt;
&lt;td&gt;Scale and latency matter more&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Batch vs stream processing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Daily reports, ML training&lt;/td&gt;
&lt;td&gt;Fraud detection, live dashboards&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Normalize vs denormalize&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Write-heavy, integrity matters&lt;/td&gt;
&lt;td&gt;Read-heavy, joins are too slow&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The phrase that signals seniority: &lt;strong&gt;"It depends on X. Given our requirement of Y, I'd choose Z, and the cost is W."&lt;/strong&gt; For a deeper treatment of how to reason through these in the room, see &lt;a href="https://www.designgurus.io/blog/complex-system-design-tradeoffs" rel="noopener noreferrer"&gt;System Design Trade-Offs: How to Navigate Them Like a Senior Engineer&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Full Worked Example: Design a News Feed
&lt;/h2&gt;

&lt;p&gt;Let's put everything together. I'll walk through "Design a news feed" (think Instagram, Facebook, or X/Twitter home timeline) exactly as I'd want a strong senior candidate to do it in 45 minutes. I'll also mark where an L4, L5, and L6 answer would differ.&lt;/p&gt;

&lt;p&gt;I picked the news feed because it touches almost every concept above: caching, sharding, queues, fan-out, hot keys, consistency, and ranking. If you can do this one well, you can adapt it to Twitter timelines, notification systems, activity feeds, and more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Requirements
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Functional (in scope):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Users can create posts (text + optional images/video).&lt;/li&gt;
&lt;li&gt;Users can follow/unfollow other users.&lt;/li&gt;
&lt;li&gt;Users see a home feed of posts from people they follow, newest first (with light ranking later).&lt;/li&gt;
&lt;li&gt;Feed supports infinite scroll.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Out of scope (said out loud):&lt;/strong&gt; comments, likes, ads, search, stories, DMs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Non-functional:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scale:&lt;/strong&gt; 500M monthly users, 200M daily active users.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Latency:&lt;/strong&gt; feed load p99 &amp;lt; 200 ms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Availability:&lt;/strong&gt; high (99.99%). A slightly stale feed is better than an error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency:&lt;/strong&gt; eventual is fine for followers (a few seconds of delay is OK), but &lt;strong&gt;authors must see their own posts immediately&lt;/strong&gt; (read-your-writes).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Durability:&lt;/strong&gt; posts must never be lost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read-heavy:&lt;/strong&gt; reads far outnumber writes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 2: Estimation
&lt;/h3&gt;

&lt;p&gt;Assumptions (state them, then compute):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;200M DAU, each opens the feed &lt;strong&gt;5 times/day&lt;/strong&gt; → &lt;strong&gt;1B feed reads/day&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;10% of DAU post once a day → &lt;strong&gt;20M new posts/day&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Average user has &lt;strong&gt;~200 followers&lt;/strong&gt;; a small number of accounts have millions.&lt;/li&gt;
&lt;li&gt;Post metadata ≈ &lt;strong&gt;1 KB&lt;/strong&gt;; 20% of posts include media averaging &lt;strong&gt;~500 KB&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Traffic:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Feed reads: 1B / 10⁵ s ≈ &lt;strong&gt;~12K QPS&lt;/strong&gt; average, &lt;strong&gt;~35K QPS&lt;/strong&gt; peak (3×).&lt;/li&gt;
&lt;li&gt;Post writes: 20M / 10⁵ ≈ &lt;strong&gt;~230 QPS&lt;/strong&gt; average, &lt;strong&gt;~700 QPS&lt;/strong&gt; peak.&lt;/li&gt;
&lt;li&gt;If we fan out on write: 20M posts × 200 followers = &lt;strong&gt;4B feed inserts/day ≈ 46K/s&lt;/strong&gt; average. This is the number that should make you pause.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Storage:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Post metadata: 20M × 1 KB = &lt;strong&gt;20 GB/day ≈ 7 TB/year&lt;/strong&gt;. Easy.&lt;/li&gt;
&lt;li&gt;Media: 4M × 500 KB = &lt;strong&gt;2 TB/day ≈ 730 TB/year&lt;/strong&gt; → object storage + CDN, not the database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Feed cache size:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep the latest &lt;strong&gt;500 post IDs&lt;/strong&gt; per active user. Each entry ≈ 16 bytes (8-byte ID + 8-byte score) → 8 KB/user.&lt;/li&gt;
&lt;li&gt;200M users × 8 KB = &lt;strong&gt;1.6 TB raw&lt;/strong&gt;, maybe &lt;strong&gt;5–8 TB&lt;/strong&gt; with Redis overhead. That's a large but very normal Redis cluster (dozens of nodes). Capping at 200 entries would cut it by more than half.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What the numbers tell us:&lt;/strong&gt; reads dominate, so precomputing feeds is worth it. But the fan-out write volume is large and spiky, so it has to be asynchronous, and celebrity accounts need special handling.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;L4 vs L5:&lt;/strong&gt; An L4 candidate often computes QPS and storage and stops. An L5 candidate notices the 46K/s fan-out number and lets it drive the design.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Step 3: API
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;posts&lt;/span&gt;
  &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;media_ids&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idempotency_key&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="na"&gt;GET /v1/feed?cursor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;
  &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;author&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;media_urls&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;next_cursor&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="no"&gt;POST&lt;/span&gt;   &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;follow&lt;/span&gt;     &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;204&lt;/span&gt;
&lt;span class="no"&gt;DELETE&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;follow&lt;/span&gt;     &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;204&lt;/span&gt;

&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;media&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;upload&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;
  &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;media_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;presigned_url&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="c1"&gt;// client uploads directly to object storage&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Design notes worth saying out loud:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cursor pagination&lt;/strong&gt; using the last post ID. Offset pagination breaks when new posts arrive at the top while you scroll.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Idempotency key&lt;/strong&gt; on post creation so a flaky mobile network doesn't create duplicate posts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pre-signed upload URLs&lt;/strong&gt; so large media goes straight to object storage, not through our app servers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 4: Data Model
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Store&lt;/th&gt;
&lt;th&gt;Key / schema&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Users&lt;/strong&gt; (relational)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;users(user_id PK, name, avatar_url, follower_count, …)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Small, relational, rarely written&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Follows&lt;/strong&gt; (sharded relational or wide-column)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;following(follower_id, followee_id, created_at)&lt;/code&gt; and &lt;code&gt;followers(followee_id, follower_id, created_at)&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Two copies, one per query direction, each sharded by its first column&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Posts&lt;/strong&gt; (wide-column, e.g., Cassandra)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;posts(post_id PK, author_id, text, media_keys, created_at)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Hydration by ID; huge, append-heavy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;User timeline&lt;/strong&gt; (wide-column)&lt;/td&gt;
&lt;td&gt;partition &lt;code&gt;author_id&lt;/code&gt;, clustering &lt;code&gt;post_id DESC&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;"Latest posts by author X," used for celebrity pull and feed rebuilds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Feed cache&lt;/strong&gt; (Redis)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;feed:{user_id}&lt;/code&gt; → sorted set of &lt;code&gt;post_id&lt;/code&gt;, scored by time&lt;/td&gt;
&lt;td&gt;Precomputed home feed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Post cache&lt;/strong&gt; (Redis/Memcached)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;post:{post_id}&lt;/code&gt; → serialized post&lt;/td&gt;
&lt;td&gt;Fast hydration of feed items&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Media&lt;/strong&gt; (object storage + CDN)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;media/{media_id}/{size}.jpg&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Blobs don't belong in a database&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Post IDs&lt;/strong&gt; are Snowflake-style 64-bit IDs: time-sortable, unique across shards, and directly usable as feed scores and pagination cursors.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: High-Level Design
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi6hiu4mvb3pu13jc89c9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi6hiu4mvb3pu13jc89c9.png" alt="News feed system design: high-level architecture with post service, Kafka, fan-out workers, feed cache, and feed service" width="800" height="553"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write path (create a post):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Client uploads media using a pre-signed URL, then calls &lt;code&gt;POST /v1/posts&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;API gateway authenticates and rate-limits the request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Post Service&lt;/strong&gt; generates a post ID, writes to the &lt;strong&gt;Posts DB&lt;/strong&gt; and the author's &lt;strong&gt;user timeline&lt;/strong&gt;, and publishes a &lt;code&gt;PostCreated&lt;/code&gt; event to &lt;strong&gt;Kafka&lt;/strong&gt;. It returns success to the client right away.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fan-out workers&lt;/strong&gt; consume the event, look up the author's followers in the &lt;strong&gt;Social Graph&lt;/strong&gt;, and add the post ID to each follower's &lt;strong&gt;feed cache&lt;/strong&gt; (&lt;code&gt;ZADD feed:{follower} {post_id} {post_id}&lt;/code&gt;), trimming each set to the latest 500 entries.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Read path (load the feed):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Client calls &lt;code&gt;GET /v1/feed&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Feed Service&lt;/strong&gt; reads the top N post IDs from &lt;code&gt;feed:{user_id}&lt;/code&gt; (starting after the cursor).&lt;/li&gt;
&lt;li&gt;It merges in recent posts from any &lt;strong&gt;celebrities&lt;/strong&gt; the user follows (more on that below).&lt;/li&gt;
&lt;li&gt;It &lt;strong&gt;hydrates&lt;/strong&gt; IDs into full posts with one multi-get against the &lt;strong&gt;Post Cache&lt;/strong&gt; (falling back to the Posts DB on misses), filters deleted or blocked content, and returns the page with media URLs pointing at the &lt;strong&gt;CDN&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At this point, we have a design that works. Now let's make it survive real traffic.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Deep Dives
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Deep Dive 1: Fan-out on Write vs Fan-out on Read
&lt;/h4&gt;

&lt;p&gt;This is the core decision in any feed design, so present all three options.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjwqxvos9hktwt5ppewp7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjwqxvos9hktwt5ppewp7.png" alt="Fan-out on write vs fan-out on read vs hybrid for news feed design" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fan-out on write (push):&lt;/strong&gt; precompute every follower's feed at post time. Reads are a single cache lookup, which is ideal for our 35K peak read QPS. But a user with 50M followers would trigger 50M writes for one post, and much of that work is wasted on followers who won't open the app today.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fan-out on read (pull):&lt;/strong&gt; compute the feed when the user opens the app by fetching recent posts from everyone they follow and merging. Writes are cheap, but each feed load becomes hundreds of queries plus a merge. That's very hard to keep under 200 ms at p99.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid (my choice):&lt;/strong&gt; push for normal accounts and pull for celebrities. If an author has more than a threshold of followers (say ~10K–100K, tuned from real data), the fan-out workers skip them. At read time, the Feed Service fetches recent posts from the handful of celebrities the user follows (from the user timeline table, heavily cached) and merges them in.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two extra optimizations worth mentioning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Only fan out to active users.&lt;/strong&gt; Skip followers who haven't logged in for, say, 30 days. When an inactive user returns, rebuild their feed with a one-time pull. This can cut fan-out volume dramatically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prioritize fan-out.&lt;/strong&gt; Use separate Kafka topics or priority lanes so a viral post's fan-out doesn't delay everyone else's.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;L5 vs L6:&lt;/strong&gt; An L5 candidate lands on the hybrid approach and explains the threshold. An L6 candidate also talks about how to choose and tune the threshold with data, what the write amplification costs in Redis memory and dollars, and how to migrate an account that crosses the threshold without double-delivering posts.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Deep Dive 2: The Feed Read Path and the 200 ms Budget
&lt;/h4&gt;

&lt;p&gt;Let's budget the p99:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gateway + auth: ~10 ms&lt;/li&gt;
&lt;li&gt;Feed cache read (&lt;code&gt;ZREVRANGEBYSCORE&lt;/code&gt;, 20–50 IDs): ~1–2 ms&lt;/li&gt;
&lt;li&gt;Celebrity merge (cached user timelines for ~5–20 celebrities): ~5–10 ms&lt;/li&gt;
&lt;li&gt;Post hydration (one batched multi-get of ~20–50 posts): ~5 ms&lt;/li&gt;
&lt;li&gt;Filtering, light ranking, serialization: ~20–40 ms&lt;/li&gt;
&lt;li&gt;Network to client: varies, but outside our server-side budget&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's comfortably under 200 ms server-side, &lt;em&gt;if&lt;/em&gt; the caches hit. So the real questions are about misses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Feed cache miss&lt;/strong&gt; (new or returning user): fall back to a pull-based rebuild, return the first page, and write the rebuilt feed to cache asynchronously.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Post cache miss:&lt;/strong&gt; batch-read from the Posts DB. Keep the post cache hit rate above ~95% by caching recent posts aggressively; most feed reads are for posts less than 48 hours old.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Deep Dive 3: Hot Keys and Celebrities
&lt;/h4&gt;

&lt;p&gt;A viral post from a celebrity means millions of reads for the same &lt;code&gt;post:{id}&lt;/code&gt; key, which all land on a single Redis shard.&lt;/p&gt;

&lt;p&gt;Mitigations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Replicate hot keys&lt;/strong&gt; across several cache nodes (e.g., &lt;code&gt;post:{id}#1&lt;/code&gt; … &lt;code&gt;#8&lt;/code&gt;) and pick one at random on read.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local in-process cache&lt;/strong&gt; (a few seconds TTL) on the Feed Service instances for the hottest posts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Request coalescing:&lt;/strong&gt; if 1,000 requests miss the same key at once, only one goes to the database.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Deep Dive 4: Consistency and Ordering
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Followers:&lt;/strong&gt; eventual consistency is fine. If fan-out takes 2–5 seconds, nobody notices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Author:&lt;/strong&gt; must see their own post instantly. Fix it by having the Feed Service always merge the author's own last few posts (from the user timeline) into their feed, or by synchronously writing to the author's own feed key before returning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ordering:&lt;/strong&gt; Snowflake IDs give us roughly time-ordered keys across shards. For a chronological feed, that's enough. For a ranked feed, ordering comes from the ranker instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deletes and privacy changes:&lt;/strong&gt; don't try to remove a deleted post from millions of feed caches. Mark it deleted (a tombstone) and filter at hydration time. The same goes for blocks and account deactivations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Deep Dive 5: Ranking (if the Interviewer Asks)
&lt;/h4&gt;

&lt;p&gt;Most real feeds aren't purely chronological. The standard approach is two-stage:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Candidate generation:&lt;/strong&gt; the precomputed feed (plus celebrity posts, plus maybe some recommended content) gives you a few hundred candidates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ranking:&lt;/strong&gt; a model scores each candidate on predicted engagement (likes, comments, dwell time) using features like author affinity, post age, and content type. You return the top 20.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep features in a low-latency feature store, and keep ranking within your latency budget. If the ranker is slow or down, &lt;strong&gt;fall back to chronological&lt;/strong&gt;. That's graceful degradation, and it's exactly the kind of detail senior interviewers look for.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Bottlenecks, Failures, and Monitoring
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What fails&lt;/th&gt;
&lt;th&gt;Impact&lt;/th&gt;
&lt;th&gt;Mitigation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A fan-out worker crashes&lt;/td&gt;
&lt;td&gt;Some feeds update late&lt;/td&gt;
&lt;td&gt;Kafka retains events; another worker resumes from the committed offset. &lt;code&gt;ZADD&lt;/code&gt; is idempotent, so replays are safe.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kafka lag spikes (viral post)&lt;/td&gt;
&lt;td&gt;Fan-out delayed for everyone&lt;/td&gt;
&lt;td&gt;Autoscale consumers on lag; separate topic for high-follower authors&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Feed cache node dies&lt;/td&gt;
&lt;td&gt;Those users see cache misses&lt;/td&gt;
&lt;td&gt;Redis replicas with automatic failover; fall back to pull-based rebuild&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Posts DB partition slow&lt;/td&gt;
&lt;td&gt;Hydration misses get slow&lt;/td&gt;
&lt;td&gt;Post cache absorbs most reads; timeouts + serve partial feed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ranking service down&lt;/td&gt;
&lt;td&gt;No ranked feed&lt;/td&gt;
&lt;td&gt;Fall back to chronological order&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Region outage&lt;/td&gt;
&lt;td&gt;Users in that region affected&lt;/td&gt;
&lt;td&gt;Multi-region deployment; route to nearest healthy region; async cross-region replication&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;What I'd monitor:&lt;/strong&gt; feed p50/p99 latency, cache hit ratios (feed and post), Kafka consumer lag, fan-out throughput, error rates per endpoint, and a business metric like "time from post creation to appearing in followers' feeds."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I'd add with more time:&lt;/strong&gt; likes and comments counters (with sharded counters to avoid hot rows), notifications, content moderation, and multi-region active-active.&lt;/p&gt;

&lt;h3&gt;
  
  
  How the Same Answer Looks at L4, L5, and L6
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;L4:&lt;/strong&gt; Gets to a working design with a cache and a database. Mentions fan-out on write. May need hints about celebrities. Solid API and data model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;L5:&lt;/strong&gt; Everything above, plus drives the conversation unprompted, uses the fan-out number from estimation to justify the hybrid model, handles hot keys and read-your-writes, and walks through failures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;L6:&lt;/strong&gt; Everything above, plus questions the requirements ("Is chronological really what the product wants?"), discusses cost (Redis memory, Kafka throughput), plans how to roll out ranking safely, and is explicit about what to build in v1 versus later.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Want more problems worked through this way?&lt;/strong&gt; &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt; applies this same framework to the classic questions, including &lt;a href="https://www.designgurus.io/course-play/grokking-the-system-design-interview/doc/designing-facebooks-newsfeed" rel="noopener noreferrer"&gt;Designing Facebook's Newsfeed&lt;/a&gt;, &lt;a href="https://www.designgurus.io/course-play/grokking-the-system-design-interview/doc/designing-twitter" rel="noopener noreferrer"&gt;Designing Twitter&lt;/a&gt;, and &lt;a href="https://www.designgurus.io/course-play/grokking-the-system-design-interview/doc/designing-instagram" rel="noopener noreferrer"&gt;Designing Instagram&lt;/a&gt;. If you're targeting L5/L6 roles, &lt;a href="https://www.designgurus.io/course/grokking-system-design-interview-ii" rel="noopener noreferrer"&gt;Grokking the System Design Interview, Volume II&lt;/a&gt; goes deeper into harder problems like payment systems and notification systems, with more advanced trade-offs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Bonus: A Template for AI System Design Questions
&lt;/h2&gt;

&lt;p&gt;Because AI questions are now common in general backend loops, here's a compact template for prompts like "Design a customer support chatbot over our docs" or "Design ChatGPT."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requirements to clarify:&lt;/strong&gt; Who are the users and what's the volume (requests/day, tokens per request)? Latency target for the first token versus the full response? Accuracy expectations, and is a wrong answer worse than "I don't know"? Data freshness? Privacy and tenant isolation? Budget per request?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The core components:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Ingestion pipeline:&lt;/strong&gt; pull documents, clean them, split them into chunks, and create embeddings. This is batch or streaming work, usually triggered by a queue.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vector store + metadata store:&lt;/strong&gt; store embeddings for semantic search, with filters (tenant, permissions, freshness).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retrieval + reranking:&lt;/strong&gt; hybrid search (vector + keyword), then a reranker to pick the best few chunks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM gateway:&lt;/strong&gt; routes to the right model, enforces rate limits and quotas, retries, and falls back to cheaper or alternate models.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generation with streaming:&lt;/strong&gt; stream tokens to the client (SSE or WebSockets) so the user sees the first token quickly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Guardrails:&lt;/strong&gt; input and output filtering, PII redaction, prompt-injection defenses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching:&lt;/strong&gt; exact-match and semantic caching of common questions to cut cost and latency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evaluation + feedback loop:&lt;/strong&gt; offline eval sets, online thumbs up/down, tracing of every request (prompt, retrieved chunks, output).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The numbers that matter:&lt;/strong&gt; tokens per request, tokens per second per GPU, cost per 1K tokens, time to first token, and GPU utilization. A quick estimate like "1M requests/day × 2K tokens = 2B tokens/day" immediately tells you whether to self-host or call a hosted API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The trade-offs to discuss:&lt;/strong&gt; bigger model versus smaller model + better retrieval; latency versus quality (reranking adds tens to hundreds of milliseconds); freshness versus indexing cost; and how to fail safely when retrieval finds nothing.&lt;/p&gt;

&lt;p&gt;I go into these question types in &lt;a href="https://dev.to/arslan_ah/ai-system-design-interview-questions-chatgpt-rag-llm-inference-and-agents-1doi"&gt;AI System Design Interview Questions: ChatGPT, RAG, LLM Inference, and Agents&lt;/a&gt;. For full, structured coverage, &lt;a href="https://www.designgurus.io/course/grokking-the-ai-system-design-interview" rel="noopener noreferrer"&gt;Grokking the AI System Design Interview&lt;/a&gt; covers ML product design, LLM and RAG architectures, and agentic systems, and there's a dedicated walkthrough of &lt;a href="https://www.designgurus.io/course-play/system-design-interview-crash-course/doc/design-chatgpt" rel="noopener noreferrer"&gt;Design ChatGPT&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Most Common System Design Interview Questions
&lt;/h2&gt;

&lt;p&gt;You can't practice every question, but you can practice the patterns behind them. Most questions fall into a handful of families. Master one or two from each and you'll recognize the shape of almost anything you're asked.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pattern family&lt;/th&gt;
&lt;th&gt;Representative questions&lt;/th&gt;
&lt;th&gt;Key concept tested&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Read-heavy + caching&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://www.designgurus.io/blog/url-shortening" rel="noopener noreferrer"&gt;URL shortener&lt;/a&gt;, Pastebin, typeahead&lt;/td&gt;
&lt;td&gt;Caching, ID generation, key-value stores&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Feeds + fan-out&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;News feed, Twitter timeline, &lt;a href="https://www.designgurus.io/course-play/grokking-the-system-design-interview/doc/designing-instagram" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;Push vs pull, hot keys&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Real-time messaging&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://www.designgurus.io/course-play/grokking-the-system-design-interview/doc/638c0b65ac93e7ae59a1afe5" rel="noopener noreferrer"&gt;Facebook Messenger&lt;/a&gt;, Slack, presence&lt;/td&gt;
&lt;td&gt;WebSockets, ordering, delivery guarantees&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Media + storage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://www.designgurus.io/course-play/grokking-the-system-design-interview/doc/638c0b68ac93e7ae59a1b009" rel="noopener noreferrer"&gt;YouTube / Netflix&lt;/a&gt;, Dropbox&lt;/td&gt;
&lt;td&gt;Object storage, CDN, chunked upload, transcoding&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Geospatial&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://www.designgurus.io/course-play/grokking-the-system-design-interview/doc/638c0b75ac93e7ae59a1b081" rel="noopener noreferrer"&gt;Uber backend&lt;/a&gt;, Yelp, food delivery&lt;/td&gt;
&lt;td&gt;Geohash/quadtree, location updates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Contention + correctness&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://www.designgurus.io/course-play/grokking-the-system-design-interview/doc/designing-ticketmaster" rel="noopener noreferrer"&gt;Ticketmaster&lt;/a&gt;, &lt;a href="https://www.designgurus.io/course-play/grokking-system-design-interview-ii/doc/design-payment-system" rel="noopener noreferrer"&gt;payment system&lt;/a&gt;, flash sales&lt;/td&gt;
&lt;td&gt;Locking, idempotency, strong consistency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Infrastructure&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://www.designgurus.io/course-play/grokking-the-system-design-interview/doc/designing-an-api-rate-limiter" rel="noopener noreferrer"&gt;Rate limiter&lt;/a&gt;, key-value store, distributed queue&lt;/td&gt;
&lt;td&gt;Partitioning, replication, consensus&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Async pipelines&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://www.designgurus.io/course-play/grokking-system-design-interview-ii/doc/designing-a-notification-system" rel="noopener noreferrer"&gt;Notification system&lt;/a&gt;, web crawler, ad click aggregator&lt;/td&gt;
&lt;td&gt;Queues, retries, stream processing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AI systems&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;ChatGPT, RAG chatbot, recommendation feed&lt;/td&gt;
&lt;td&gt;Retrieval, model serving, cost&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For a full list ordered by difficulty, see &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m"&gt;64 System Design Interview Questions, Ranked From Easiest to Hardest&lt;/a&gt;, and for how to approach the most-asked ones, &lt;a href="https://www.designgurus.io/blog/system-design-interview-questions" rel="noopener noreferrer"&gt;Top System Design Interview Questions and How to Tackle Them&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  12 Mistakes That Sink Strong Candidates
&lt;/h2&gt;

&lt;p&gt;I've seen excellent engineers fail system design rounds for reasons that had nothing to do with their ability. These are the most common ones.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Jumping straight into boxes.&lt;/strong&gt; Designing before clarifying requirements is the most common mistake, and interviewers notice it in the first two minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asking questions without proposing answers.&lt;/strong&gt; "How many users?" is fine. "I'll assume 100M DAU, read-heavy, does that sound right?" is better.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Estimation theater.&lt;/strong&gt; Ten minutes of arithmetic that never influences a decision.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Buzzword architecture.&lt;/strong&gt; Kafka, Kubernetes, and microservices everywhere, with no reason given. Every component needs a "because."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Going deep too early.&lt;/strong&gt; Spending 20 minutes on database internals before you have an end-to-end design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Staying shallow everywhere.&lt;/strong&gt; The opposite problem: a complete diagram with no depth anywhere. Pick two or three areas and go deep.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Presenting one option as the only option.&lt;/strong&gt; Senior candidates compare alternatives before committing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ignoring failure.&lt;/strong&gt; Never asking "what happens when this dies?"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forgetting the data model.&lt;/strong&gt; Many designs fall apart because nobody decided how data is keyed and partitioned.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not listening to hints.&lt;/strong&gt; When the interviewer says "What about users with millions of followers?", that's not small talk. It's the deep dive they want.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Going silent.&lt;/strong&gt; The interviewer can only grade what they hear. Think out loud.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memorizing instead of understanding.&lt;/strong&gt; A memorized answer collapses the moment the interviewer adds a twist ("Now make it work across three regions").&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I cover the misconceptions behind many of these in &lt;a href="https://dev.to/arslan_ah/the-9-things-engineers-get-wrong-about-the-system-design-interview-and-the-185-articles-i-wrote-to-22p1"&gt;The 9 Things Engineers Get Wrong About the System Design Interview&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  An 8-Week Preparation Plan
&lt;/h2&gt;

&lt;p&gt;Here's a realistic plan for a working engineer with about 6 to 8 hours a week. If you already build distributed systems at work, you can compress it to about four weeks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4tozpphc7qfefp897dpe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4tozpphc7qfefp897dpe.png" alt="An 8-week system design interview preparation plan" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Weeks 1–2: Fundamentals.&lt;/strong&gt; Work through the 15 concepts in this guide. For each, make sure you can explain what it is, when to use it, and what it costs. Use the &lt;a href="https://www.designgurus.io/blog/system-design-cheat-sheet" rel="noopener noreferrer"&gt;System Design Cheat Sheet&lt;/a&gt; as a checklist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Weeks 3–4: Framework + classics.&lt;/strong&gt; Practice the 7-step framework on four or five classic problems: URL shortener, rate limiter, news feed, chat, and file storage. Do one estimation drill (about 10 minutes) every day. After each problem, write a one-page summary of the key decisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Weeks 5–6: Depth + modern topics.&lt;/strong&gt; Move to harder problems (Ticketmaster, payments, notifications, a distributed key-value store) and modern topics (stream processing, sagas, AI systems). Focus on deep dives and failure handling. If you're preparing for microservices-heavy roles, &lt;a href="https://www.designgurus.io/course/grokking-microservices-for-system-design-interviews" rel="noopener noreferrer"&gt;Grokking Microservices for System Design Interviews&lt;/a&gt; covers when microservices are (and aren't) the right call and how to defend that choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Weeks 7–8: Mocks + polish.&lt;/strong&gt; Do two or three timed mock interviews a week, ideally with someone who has interviewed candidates before. Record yourself. Practice the first five minutes until they're automatic. If you don't have a practice partner, our &lt;a href="https://www.designgurus.io/mock-interviews" rel="noopener noreferrer"&gt;mock interviews&lt;/a&gt; pair you with engineers from big tech companies who give you rubric-based feedback.&lt;/p&gt;

&lt;p&gt;For more detail on timelines by experience level, read &lt;a href="https://www.designgurus.io/blog/how-long-to-prepare-for-system-design-interview" rel="noopener noreferrer"&gt;How Long Does It Take to Prepare for a System Design Interview?&lt;/a&gt;. And if you're starting from zero, &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-from-scratch-with-no-distributed-systems-experience-1591"&gt;How to Learn System Design From Scratch&lt;/a&gt; is a good first read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Resources to Prepare
&lt;/h2&gt;

&lt;p&gt;These are the resources I'd recommend, grouped by where you are in your prep. Full disclosure again: the courses are ours at DesignGurus.io, and I built them for exactly this interview.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Courses&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt;:&lt;/strong&gt; the original course. It teaches the 7-step framework and applies it to the classic questions. Start here if you have an interview coming up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals" rel="noopener noreferrer"&gt;Grokking System Design Fundamentals&lt;/a&gt;:&lt;/strong&gt; for beginners. Covers scaling, load balancing, caching, databases, and CAP from the ground up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-scalable-systems-for-interviews" rel="noopener noreferrer"&gt;Grokking Scalable Systems for Interviews&lt;/a&gt;:&lt;/strong&gt; for people who know the definitions but struggle to apply them. Caching, sharding, replication, observability, and fault tolerance as design decisions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-system-design-interview-ii" rel="noopener noreferrer"&gt;Grokking the System Design Interview, Volume II&lt;/a&gt;:&lt;/strong&gt; for L5/L6 candidates. Harder problems and deeper trade-offs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-the-ai-system-design-interview" rel="noopener noreferrer"&gt;Grokking the AI System Design Interview&lt;/a&gt;:&lt;/strong&gt; ML products, LLM and RAG architectures, and agentic systems.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-microservices-for-system-design-interviews" rel="noopener noreferrer"&gt;Grokking Microservices for System Design Interviews&lt;/a&gt;:&lt;/strong&gt; when microservices are the right call, and how to defend that choice in an interview.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Free articles from the DesignGurus.io blog&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.designgurus.io/blog/step-by-step-guide" rel="noopener noreferrer"&gt;System Design Interview Guide – 7 Steps to Ace It&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.designgurus.io/blog/back-of-the-envelope-system-design-interview" rel="noopener noreferrer"&gt;Back-of-the-Envelope Estimation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.designgurus.io/blog/complex-system-design-tradeoffs" rel="noopener noreferrer"&gt;System Design Trade-Offs: How to Navigate Them Like a Senior Engineer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.designgurus.io/blog/consistency-patterns-distributed-systems" rel="noopener noreferrer"&gt;Consistency Patterns in Distributed Systems&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.designgurus.io/blog/system-design-patterns-complete-guide" rel="noopener noreferrer"&gt;System Design Patterns: The Complete Guide (60+ Patterns)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.designgurus.io/blog/system-design-cheat-sheet" rel="noopener noreferrer"&gt;System Design Cheat Sheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.designgurus.io/blog/url-shortening" rel="noopener noreferrer"&gt;How to Design a URL Shortener: A Step-by-Step Guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Related guide:&lt;/strong&gt; &lt;a href="https://arslan-ahmad.medium.com/the-complete-system-design-interview-guide-for-2027-85a1ab94ace7" rel="noopener noreferrer"&gt;The Complete System Design Interview Guide for 2027&lt;/a&gt;, my complete write-up of the 2027 interview: the framework, what interviewers score, and a full worked example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Video:&lt;/strong&gt; the &lt;a href="https://www.youtube.com/channel/UCupx1O-omoKq73JS3p6jlvQ" rel="noopener noreferrer"&gt;Design Gurus YouTube channel&lt;/a&gt; has short explainers on caching, Kafka, consistent hashing, idempotency, and more, plus full walkthroughs like &lt;a href="https://www.youtube.com/watch?v=zFXUxjlOCoo" rel="noopener noreferrer"&gt;How to answer any system design interview question&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Books and papers:&lt;/strong&gt; &lt;em&gt;Designing Data-Intensive Applications&lt;/em&gt; by Martin Kleppmann is the best single book on the underlying concepts. The Amazon Dynamo, Google Bigtable, and Google Spanner papers are worth skimming once you know the basics.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How long should I prepare for a system design interview?
&lt;/h3&gt;

&lt;p&gt;Most working engineers need 4 to 8 weeks at 6 to 8 hours a week. If you already work on distributed systems, 2 to 4 weeks of focused practice on the framework and mock interviews is often enough. If you're new to backend systems, plan for 8 to 12 weeks and start with fundamentals.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need distributed systems experience to pass?
&lt;/h3&gt;

&lt;p&gt;No. Interviewers test reasoning, not résumé items. Many candidates pass after learning the building blocks and practicing the framework on 10–15 problems. What you can't fake is the ability to explain &lt;em&gt;why&lt;/em&gt; you chose something, so focus on trade-offs, not memorization.&lt;/p&gt;

&lt;h3&gt;
  
  
  Are system design interviews asked for junior and new-grad roles?
&lt;/h3&gt;

&lt;p&gt;Less often, and with a lower bar. Some companies include a lighter design round or an object-oriented design round for new grads. For mid-level (L4) roles and above, expect at least one system design round. For senior and staff roles, it's often the most important round in the loop.&lt;/p&gt;

&lt;h3&gt;
  
  
  What if I don't know a specific technology the interviewer mentions?
&lt;/h3&gt;

&lt;p&gt;Say so, and reason from first principles. "I haven't used Cassandra in production, but if it's a leaderless, partitioned wide-column store, then I'd expect writes to be cheap and cross-partition queries to be expensive, so I'd model the data around the partition key." That's a strong answer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I memorize designs for popular questions?
&lt;/h3&gt;

&lt;p&gt;Memorize patterns, not answers. Know the shape of a feed, a chat system, a rate limiter, and a booking system. Then adapt to the specific requirements you're given. Interviewers often add a twist precisely to see whether you're reciting.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I practice system design on my own?
&lt;/h3&gt;

&lt;p&gt;Pick a question, set a 45-minute timer, and talk through it out loud while drawing (recording yourself helps a lot). Then compare your design with a reference solution and note what you missed. Do at least a few mocks with another person, because handling interruptions and hints is a separate skill.&lt;/p&gt;

&lt;h3&gt;
  
  
  How are AI tools changing the system design interview?
&lt;/h3&gt;

&lt;p&gt;Two ways. First, AI system design questions (RAG, LLM serving, agents) are now common, so learn the basic components and cost math. Second, some companies have started allowing AI assistance in parts of their loops. Rules vary by company, so ask your recruiter. Either way, the judgment calls (what to build, what to trade off, and why) are still yours to make and explain.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's the single most important thing to get right?
&lt;/h3&gt;

&lt;p&gt;The first 15 minutes. Clear requirements, quick estimates, a clean API, and a sensible data model make everything after them easier, and they're the part most candidates rush.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The system design interview rewards a specific kind of thinking: start from requirements, let numbers guide decisions, keep the design as simple as the problem allows, and be honest about trade-offs. That's also what good engineering looks like on the job, which is why companies keep using this interview.&lt;/p&gt;

&lt;p&gt;If you take one thing from this playbook, make it the framework. Practice it on ten problems, out loud, under a timer. By the tenth, you'll notice that the questions stop feeling like ten different problems and start looking like variations on a few patterns you already know.&lt;/p&gt;

&lt;p&gt;Good luck. If this helped, share it with someone who's preparing, and tell me in the comments which question you'd like me to work through next.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;— Arslan&lt;/em&gt;&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>interview</category>
      <category>career</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Grokking the System Design Interview: How to Design a Rate Limiter (Step by Step)</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Tue, 06 Oct 2026 08:09:16 +0000</pubDate>
      <link>https://dev.to/arslan_ah/grokking-the-system-design-interview-how-to-design-a-rate-limiter-step-by-step-5g25</link>
      <guid>https://dev.to/arslan_ah/grokking-the-system-design-interview-how-to-design-a-rate-limiter-step-by-step-5g25</guid>
      <description>&lt;p&gt;"Design a rate limiter."&lt;/p&gt;

&lt;p&gt;It sounds small. It is not.&lt;/p&gt;

&lt;p&gt;This question shows up at Stripe, Google, Amazon, Cloudflare, and almost every company that runs a public API. It is short enough to fit in 45 minutes. But it is deep enough to separate a junior answer from a senior one.&lt;/p&gt;

&lt;p&gt;In this post, I will walk through the problem the way we teach it in Grokking the System Design Interview. Step by step. Requirements first, then estimates, then algorithms, then architecture, then the hard parts. If you are new to this interview format, &lt;a href="https://arslan-ahmad.medium.com/the-complete-system-design-interview-guide-for-2027-85a1ab94ace7" rel="noopener noreferrer"&gt;The Complete System Design Interview Guide for 2027&lt;/a&gt; covers the full framework; this post applies it to one question.&lt;/p&gt;

&lt;p&gt;Let's go.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Rate Limiter?
&lt;/h2&gt;

&lt;p&gt;A rate limiter controls how many requests a client can send in a given time window.&lt;/p&gt;

&lt;p&gt;If a user is allowed 100 requests per minute, request number 101 gets rejected. Usually with an HTTP &lt;code&gt;429 Too Many Requests&lt;/code&gt; response.&lt;/p&gt;

&lt;p&gt;Think of it like a nightclub bouncer with a clicker. The club holds 200 people. The bouncer counts everyone who walks in. When the counter hits 200, the next person waits outside. Nobody is being rude. The building just has a limit.&lt;/p&gt;

&lt;p&gt;Rate limiters exist for three main reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Protect your servers.&lt;/strong&gt; One buggy script or one bad actor should not take down the whole service.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Control costs.&lt;/strong&gt; If every request hits a paid third-party API, unlimited traffic means an unlimited bill.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep things fair.&lt;/strong&gt; One heavy user should not slow the system down for everyone else.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Clarify the Requirements
&lt;/h2&gt;

&lt;p&gt;Never start drawing boxes right away. Ask questions first. In a real interview, this is where you earn your first points.&lt;/p&gt;

&lt;p&gt;Here are the questions I would ask:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Client-side or server-side?&lt;/strong&gt; Server-side. Client-side limits are easy to bypass.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What do we limit by?&lt;/strong&gt; User ID, IP address, API key, or a mix. Let's support all of them through configurable rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What scale?&lt;/strong&gt; Think large. Millions of users, a few hundred thousand requests per second at peak.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distributed?&lt;/strong&gt; Yes. Many API servers sit behind a load balancer. The limit must hold across all of them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What happens when a request is throttled?&lt;/strong&gt; Return &lt;code&gt;429&lt;/code&gt; with headers that tell the client when to retry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hard or soft limit?&lt;/strong&gt; Mostly hard. A tiny overshoot during a race is acceptable if it keeps latency low.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From those answers, we can write the requirements down.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functional requirements&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Limit requests per client based on configurable rules (for example, 100 requests per minute per user).&lt;/li&gt;
&lt;li&gt;Return &lt;code&gt;429&lt;/code&gt; when a client exceeds the limit.&lt;/li&gt;
&lt;li&gt;Tell the client its remaining quota through response headers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Non-functional requirements&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Low latency.&lt;/strong&gt; The check sits on every request. It must add only a millisecond or two.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Highly available.&lt;/strong&gt; If the rate limiter breaks, the API should not break with it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accurate enough.&lt;/strong&gt; Small errors are fine. Letting 10x the limit through is not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalable.&lt;/strong&gt; Works across many servers and regions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 2: Back-of-the-Envelope Estimates
&lt;/h2&gt;

&lt;p&gt;Let's keep the math simple.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;10 million daily active users.&lt;/li&gt;
&lt;li&gt;Peak traffic of 200,000 requests per second.&lt;/li&gt;
&lt;li&gt;Each counter needs a key (about 50 bytes) plus a count and a timestamp (about 16 bytes). Call it roughly 100 bytes with overhead.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Memory for 10 million active counters:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;10,000,000 x 100 bytes = 1 GB&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That fits in memory on a single Redis node. But 200,000 checks per second, with a read and a write each, is better spread across a small Redis cluster. That also gives us replication for availability.&lt;/p&gt;

&lt;p&gt;The takeaway: &lt;strong&gt;storage is cheap here. Latency and coordination are the real problems.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Pick a Rate Limiting Algorithm
&lt;/h2&gt;

&lt;p&gt;This is the heart of the interview. There are five classic algorithms. You do not need all of them in detail, but you should know the trade-offs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgcw2l2j55go1y27dupdd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgcw2l2j55go1y27dupdd.png" alt="5 rate limiting algorithms compared: token bucket, leaky bucket, fixed window, sliding window log, sliding window counter" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Token Bucket
&lt;/h3&gt;

&lt;p&gt;A bucket holds tokens. Tokens refill at a fixed rate. Every request takes one token. No token, no entry.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bucket size = how big a burst you allow.&lt;/li&gt;
&lt;li&gt;Refill rate = your long-term average limit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Simple. Memory efficient. Allows short bursts, which matches real user behavior.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; Two parameters to tune.&lt;/p&gt;

&lt;p&gt;This is what Amazon API Gateway and Stripe use. It is the safest default in an interview.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkswaava0r9wo66c0hxdg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkswaava0r9wo66c0hxdg.png" alt="Token bucket flow: refill, check tokens, allow or reject with 429" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Leaky Bucket
&lt;/h3&gt;

&lt;p&gt;Requests enter a queue. The queue drains at a fixed rate, like water leaking from a hole in a bucket. If the queue is full, new requests are dropped.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Produces a perfectly smooth output rate.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; Bursts of traffic fill the queue with old requests. Recent requests get starved.&lt;/p&gt;

&lt;p&gt;Good for systems that need steady processing, like a payment processor that calls a bank API.&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Fixed Window Counter
&lt;/h3&gt;

&lt;p&gt;Split time into fixed windows, like one minute each. Keep one counter per window. Reject when the counter passes the limit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Very simple. One counter per user.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; The edge problem. A user can send 100 requests at 12:00:59 and another 100 at 12:01:00. That is 200 requests in two seconds, double the limit.&lt;/p&gt;
&lt;h3&gt;
  
  
  4. Sliding Window Log
&lt;/h3&gt;

&lt;p&gt;Store the timestamp of every request. On each new request, drop timestamps older than the window and count what is left.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Perfectly accurate.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; Memory heavy. A limit of 1,000 requests per hour means storing up to 1,000 timestamps per user.&lt;/p&gt;
&lt;h3&gt;
  
  
  5. Sliding Window Counter
&lt;/h3&gt;

&lt;p&gt;A hybrid. Keep counters for the current and previous window. Estimate the count with a weighted average.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;estimate = current_count + previous_count x (overlap percentage of previous window)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If we are 30% into the current minute, the previous minute still overlaps by 70%. So with 80 requests last minute and 20 so far this minute:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;20 + 80 x 0.7 = 76&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Smooths out the edge problem. Memory efficient.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; It is an approximation. Cloudflare measured it at about 0.003% error across 400 million requests, which is more than good enough.&lt;/p&gt;
&lt;h3&gt;
  
  
  Quick Comparison
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Algorithm&lt;/th&gt;
&lt;th&gt;Memory&lt;/th&gt;
&lt;th&gt;Accuracy&lt;/th&gt;
&lt;th&gt;Allows bursts&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Token bucket&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;General API limits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Leaky bucket&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;td&gt;No (smooths)&lt;/td&gt;
&lt;td&gt;Steady downstream calls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fixed window&lt;/td&gt;
&lt;td&gt;Very low&lt;/td&gt;
&lt;td&gt;Weak at edges&lt;/td&gt;
&lt;td&gt;Yes, at edges&lt;/td&gt;
&lt;td&gt;Simple, low-stakes limits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sliding window log&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Exact&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Strict, low-volume limits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sliding window counter&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Very good&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;td&gt;High-scale APIs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;What I would say in the interview:&lt;/strong&gt; "I will go with the token bucket as the default because it is cheap, handles bursts, and is used in production by large API providers. If the business needs strict smoothing, I would switch to sliding window counter."&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 4: High-Level Design
&lt;/h2&gt;

&lt;p&gt;Now we draw boxes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fua1m757ptus9q5n3p0i1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fua1m757ptus9q5n3p0i1.png" alt="Rate limiter high-level design with API gateway, Redis cluster and rules service" width="799" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Client&lt;/strong&gt; sends a request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Gateway / Rate Limiter middleware&lt;/strong&gt; receives it. This is where the check happens.&lt;/li&gt;
&lt;li&gt;The middleware builds a key, like &lt;code&gt;rate:user:42&lt;/code&gt;, and checks the counter in &lt;strong&gt;Redis&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rules Service&lt;/strong&gt; stores the limits (for example, free tier gets 100 per minute, paid tier gets 1,000). The middleware caches these rules locally and refreshes them every few seconds.&lt;/li&gt;
&lt;li&gt;If the client is under the limit, the request goes to the &lt;strong&gt;API servers&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If not, the middleware returns &lt;code&gt;429&lt;/code&gt; right away. The backend never sees it.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Where should the rate limiter live?
&lt;/h3&gt;

&lt;p&gt;Three options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inside each service.&lt;/strong&gt; Simple, but every team rebuilds the same logic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In the API gateway.&lt;/strong&gt; Central and consistent. This is the common choice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;As a separate service.&lt;/strong&gt; Flexible, but adds a network hop to every request.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would pick the API gateway. If the company already runs a gateway like Kong, Envoy, or AWS API Gateway, rate limiting is a plugin away.&lt;/p&gt;
&lt;h3&gt;
  
  
  Why Redis?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In-memory, so reads and writes take under a millisecond.&lt;/li&gt;
&lt;li&gt;Built-in &lt;code&gt;INCR&lt;/code&gt; and &lt;code&gt;EXPIRE&lt;/code&gt; commands.&lt;/li&gt;
&lt;li&gt;Supports Lua scripts, which run atomically. That matters a lot. More on that next.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Response headers
&lt;/h3&gt;

&lt;p&gt;Be kind to clients. Tell them where they stand.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt; &lt;span class="m"&gt;429&lt;/span&gt; &lt;span class="ne"&gt;Too Many Requests&lt;/span&gt;
&lt;span class="na"&gt;X-RateLimit-Limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;100&lt;/span&gt;
&lt;span class="na"&gt;X-RateLimit-Remaining&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;0&lt;/span&gt;
&lt;span class="na"&gt;X-RateLimit-Reset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1696608000&lt;/span&gt;
&lt;span class="na"&gt;Retry-After&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;30&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Good clients read these headers and back off on their own. That reduces load before the limiter even has to say no.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Deep Dives (Where Senior Candidates Shine)
&lt;/h2&gt;

&lt;p&gt;A basic design gets you to "hire" at the mid level. These deep dives push you toward senior and staff.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Dive 1: Race Conditions
&lt;/h3&gt;

&lt;p&gt;Picture two API servers handling requests from the same user at the same moment.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Server A reads the counter: 99.&lt;/li&gt;
&lt;li&gt;Server B reads the counter: 99.&lt;/li&gt;
&lt;li&gt;Both see "under 100" and allow the request.&lt;/li&gt;
&lt;li&gt;Both write 100.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two requests went through. The counter says one. Do this at scale and limits leak badly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Make read-check-write a single atomic step. In Redis, use a Lua script. Redis runs each script start to finish without interruption.&lt;/p&gt;

&lt;p&gt;Here is a token bucket in Lua:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lua"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- KEYS[1] = bucket key&lt;/span&gt;
&lt;span class="c1"&gt;-- ARGV[1] = capacity, ARGV[2] = refill rate per second, ARGV[3] = now (ms)&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;capacity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;tonumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ARGV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;tonumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ARGV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;tonumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ARGV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"HMGET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KEYS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;"tokens"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;tonumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;capacity&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;ts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;tonumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;

&lt;span class="c1"&gt;-- refill based on elapsed time&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;elapsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;math.max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;ts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;
&lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;math.min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;elapsed&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;allowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="n"&gt;allowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"HMSET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KEYS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;"tokens"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"EXPIRE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KEYS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nb"&gt;math.ceil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;capacity&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;math.floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One network round trip. No races. No locks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Dive 2: Scaling Redis
&lt;/h3&gt;

&lt;p&gt;One Redis node will not last forever. Shard the keys across a Redis cluster using consistent hashing on the client key. All counters for &lt;code&gt;user:42&lt;/code&gt; land on the same shard, so the Lua script still works.&lt;/p&gt;

&lt;p&gt;Add a replica per shard for failover.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Dive 3: What If Redis Goes Down?
&lt;/h3&gt;

&lt;p&gt;This is a favorite follow-up. You have two choices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fail open.&lt;/strong&gt; Let all requests through. The API stays up, but you lose protection for a while.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail closed.&lt;/strong&gt; Reject all requests. You stay protected, but your API is effectively down.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For most products, &lt;strong&gt;fail open&lt;/strong&gt; is the right call. A short window without limits hurts less than a full outage. Pair it with a local in-memory fallback limiter on each gateway node, so you still get rough protection.&lt;/p&gt;

&lt;p&gt;For security-critical limits, like login attempts, fail closed may be the safer choice. Say this trade-off out loud. Interviewers love it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Dive 4: Multi-Region
&lt;/h3&gt;

&lt;p&gt;If you run in three regions, a global limit gets tricky. Syncing every counter across regions on every request adds too much latency.&lt;/p&gt;

&lt;p&gt;Common approaches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local limits per region.&lt;/strong&gt; Split the global limit (for example, 1,000 per minute becomes about 333 per region). Simple, slightly inaccurate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Async sync.&lt;/strong&gt; Each region counts locally and syncs totals every second or so. Accepts a small overshoot for much lower latency.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most real systems choose eventual consistency here. Perfect global accuracy is rarely worth the cost.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Dive 5: Reducing Load on Redis
&lt;/h3&gt;

&lt;p&gt;At very high traffic, even Redis can become a hot spot. Two tricks help:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local pre-check.&lt;/strong&gt; Each gateway keeps a small in-memory counter and only syncs with Redis in batches.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hot key handling.&lt;/strong&gt; A single huge customer can overload one shard. Split their key into sub-keys (&lt;code&gt;rate:user:42:0&lt;/code&gt; to &lt;code&gt;rate:user:42:3&lt;/code&gt;) and divide their limit across them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Interviewers Actually Look For
&lt;/h2&gt;

&lt;p&gt;Here is how I would grade this question, based on years of running these interviews.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;What a strong answer includes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Junior / Mid&lt;/td&gt;
&lt;td&gt;Clear requirements, one algorithm explained well, gateway plus Redis design&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Senior&lt;/td&gt;
&lt;td&gt;Compares algorithms with trade-offs, solves race conditions, discusses fail open vs fail closed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Staff&lt;/td&gt;
&lt;td&gt;Multi-region strategy, hot keys, rule management, and how clients should react to &lt;code&gt;429&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You do not need every deep dive. Pick two and go deep. Depth beats breadth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes to Avoid
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Jumping to Redis before asking a single question.&lt;/li&gt;
&lt;li&gt;Explaining five algorithms and never picking one.&lt;/li&gt;
&lt;li&gt;Forgetting the race condition.&lt;/li&gt;
&lt;li&gt;Ignoring what happens when the rate limiter itself fails.&lt;/li&gt;
&lt;li&gt;Storing counters in a relational database. Too slow for a per-request check.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A rate limiter caps how many requests a client can make in a time window.&lt;/li&gt;
&lt;li&gt;Always clarify: what to limit by, scale, distributed or not, hard or soft limits.&lt;/li&gt;
&lt;li&gt;Token bucket is the best default. Sliding window counter is great for high-scale accuracy.&lt;/li&gt;
&lt;li&gt;Put the limiter in the API gateway and store counters in Redis.&lt;/li&gt;
&lt;li&gt;Use Lua scripts to make the check atomic and avoid race conditions.&lt;/li&gt;
&lt;li&gt;Fail open for most APIs. Fail closed for security-critical limits.&lt;/li&gt;
&lt;li&gt;For multiple regions, accept small inaccuracy in exchange for low latency.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What HTTP status code should a rate limiter return?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;429 Too Many Requests&lt;/code&gt;, along with a &lt;code&gt;Retry-After&lt;/code&gt; header that tells the client when to try again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which rate limiting algorithm is best?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
There is no single best one. Token bucket is the most common default because it is simple, cheap, and allows short bursts. Sliding window counter is better when you need smoother limits at scale.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why use Redis instead of a database?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The check runs on every single request. Redis is in-memory and answers in under a millisecond. A disk-based database would add too much latency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the difference between token bucket and leaky bucket?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Token bucket allows bursts up to the bucket size. Leaky bucket smooths everything into a steady output rate, even if requests arrive in bursts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Should the rate limiter fail open or fail closed?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Usually fail open, so a limiter outage does not become an API outage. For login or payment endpoints, failing closed can be safer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long should I spend on this in a 45-minute interview?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
About 5 minutes on requirements, 5 on estimates, 10 on algorithms, 10 on the high-level design, and the rest on one or two deep dives.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;The rate limiter is a great interview question because it looks easy. The candidates who stand out are the ones who slow down, ask the right questions, and talk openly about trade-offs.&lt;/p&gt;

&lt;p&gt;If you want the full picture of how this round is scored in 2027, from the framework to the level-by-level expectations, read &lt;a href="https://arslan-ahmad.medium.com/the-complete-system-design-interview-guide-for-2027-85a1ab94ace7" rel="noopener noreferrer"&gt;The Complete System Design Interview Guide for 2027&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you want more walkthroughs like this one, including URL shorteners, news feeds, and chat systems, they are all covered in &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Which system design question should I break down next? Let me know in the comments.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>architecture</category>
      <category>interview</category>
      <category>backend</category>
    </item>
    <item>
      <title>LeetCode Patterns: The Complete List of 20 to Master (With Examples)</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Tue, 06 Oct 2026 04:55:28 +0000</pubDate>
      <link>https://dev.to/arslan_ah/leetcode-patterns-the-complete-list-of-20-to-master-with-examples-nff</link>
      <guid>https://dev.to/arslan_ah/leetcode-patterns-the-complete-list-of-20-to-master-with-examples-nff</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;The complete list of 20 LeetCode patterns. Each one carries the signal that identifies it in a problem statement, a code template you can reuse, and three practice problems on LeetCode. Pattern problem counts come from LeetCode's own topic tags.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;LeetCode has 4,073 problems. Nobody solves them all, and nobody needs to.&lt;/p&gt;

&lt;p&gt;The questions are generated from a much smaller set of reusable approaches. Learn to recognize those, and a problem you have never seen becomes a variation of one you have. Miss them, and every question feels new, which is why solving hundreds of problems at random produces so little.&lt;/p&gt;

&lt;p&gt;This guide covers all 20 patterns. For each one you get the cue that gives it away, why it works, a short template in Python, and three real LeetCode problems to practice on. The order is by what each pattern returns against LeetCode's actual problem distribution, so the earliest entries are the ones worth learning first.&lt;/p&gt;

&lt;p&gt;You will see these called LeetCode patterns, LC patterns, coding patterns, or DSA patterns. They are the same thing: a reusable approach that pairs an algorithmic technique with the data structure it runs on. A single LeetCode pattern is worth more than a hundred solved problems, because the pattern transfers and the solved problem does not.&lt;/p&gt;

&lt;p&gt;If you want the same 20 as a short reference instead, see the &lt;a href="https://www.designgurus.io/blog/grokking-the-coding-interview-patterns?utm_source=devto" rel="noopener noreferrer"&gt;coding interview patterns catalog&lt;/a&gt;. If you want to train the recognition skill itself rather than read the list, see &lt;a href="https://www.grokkingthecodinginterview.com/blog/leetcode-patterns" rel="noopener noreferrer"&gt;how to read a problem statement and name the pattern&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  All 20 LeetCode Patterns
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Two Pointers&lt;/li&gt;
&lt;li&gt;Sliding Window&lt;/li&gt;
&lt;li&gt;Modified Binary Search&lt;/li&gt;
&lt;li&gt;Tree Depth First Search&lt;/li&gt;
&lt;li&gt;Tree Breadth First Search&lt;/li&gt;
&lt;li&gt;Island (Matrix Traversal)&lt;/li&gt;
&lt;li&gt;0/1 Knapsack (Dynamic Programming)&lt;/li&gt;
&lt;li&gt;Top 'K' Elements&lt;/li&gt;
&lt;li&gt;Backtracking&lt;/li&gt;
&lt;li&gt;Subsets&lt;/li&gt;
&lt;li&gt;Bitwise XOR&lt;/li&gt;
&lt;li&gt;Fast &amp;amp; Slow Pointers&lt;/li&gt;
&lt;li&gt;Merge Intervals&lt;/li&gt;
&lt;li&gt;Monotonic Stack&lt;/li&gt;
&lt;li&gt;Topological Sort&lt;/li&gt;
&lt;li&gt;In-place Reversal of a Linked List&lt;/li&gt;
&lt;li&gt;Two Heaps&lt;/li&gt;
&lt;li&gt;Cyclic Sort&lt;/li&gt;
&lt;li&gt;K-way Merge&lt;/li&gt;
&lt;li&gt;Multi-threaded&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fos2dv7d7x2t9n7q0rh0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fos2dv7d7x2t9n7q0rh0g.png" alt="The 20 LeetCode patterns at a glance" width="800" height="724"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The 20 Patterns at a Glance
&lt;/h2&gt;

&lt;p&gt;Problem counts are LeetCode topic-tag totals, pulled from LeetCode. A few patterns share a tag and two have no dedicated tag, which is noted rather than guessed.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pattern&lt;/th&gt;
&lt;th&gt;Recognize it by&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;th&gt;LeetCode problems&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. Two Pointers
&lt;/td&gt;
&lt;td&gt;sorted input, find a pair or triplet&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;263&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. Sliding Window
&lt;/td&gt;
&lt;td&gt;longest or shortest contiguous run&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;175&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. Modified Binary Search
&lt;/td&gt;
&lt;td&gt;sorted or rotated, or a testable answer&lt;/td&gt;
&lt;td&gt;O(log n) time&lt;/td&gt;
&lt;td&gt;356&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. Tree Depth First Search
&lt;/td&gt;
&lt;td&gt;root-to-leaf path, or a subtree answer&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;349&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5. Tree Breadth First Search
&lt;/td&gt;
&lt;td&gt;levels, or fewest steps&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;260&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6. Island (Matrix Traversal)
&lt;/td&gt;
&lt;td&gt;a grid, count connected regions&lt;/td&gt;
&lt;td&gt;O(m*n) time&lt;/td&gt;
&lt;td&gt;285&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7. 0/1 Knapsack (Dynamic Programming)
&lt;/td&gt;
&lt;td&gt;pick a subset under a capacity&lt;/td&gt;
&lt;td&gt;O(n*C) time&lt;/td&gt;
&lt;td&gt;684&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8. Top 'K' Elements
&lt;/td&gt;
&lt;td&gt;k largest, smallest, or most frequent&lt;/td&gt;
&lt;td&gt;O(n log k) time&lt;/td&gt;
&lt;td&gt;222&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9. Backtracking
&lt;/td&gt;
&lt;td&gt;list every valid configuration&lt;/td&gt;
&lt;td&gt;O(b^d) time&lt;/td&gt;
&lt;td&gt;114&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10. Subsets
&lt;/td&gt;
&lt;td&gt;every combination or power set&lt;/td&gt;
&lt;td&gt;O(n * 2^n) time&lt;/td&gt;
&lt;td&gt;114&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11. Bitwise XOR
&lt;/td&gt;
&lt;td&gt;values pair off, find the odd one out&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;297&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12. Fast &amp;amp; Slow Pointers
&lt;/td&gt;
&lt;td&gt;cycle, middle, or kth from the end&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;263&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13. Merge Intervals
&lt;/td&gt;
&lt;td&gt;ranges or time slots that overlap&lt;/td&gt;
&lt;td&gt;O(n log n) time&lt;/td&gt;
&lt;td&gt;no dedicated tag&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;14. Monotonic Stack
&lt;/td&gt;
&lt;td&gt;next greater or next smaller element&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;76&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;15. Topological Sort
&lt;/td&gt;
&lt;td&gt;prerequisites, ordering, cycle check&lt;/td&gt;
&lt;td&gt;O(V+E) time&lt;/td&gt;
&lt;td&gt;40&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16. In-place Reversal of a Linked List
&lt;/td&gt;
&lt;td&gt;reverse a list without new memory&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;82&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;17. Two Heaps
&lt;/td&gt;
&lt;td&gt;running median, or a split set&lt;/td&gt;
&lt;td&gt;O(log n) insert&lt;/td&gt;
&lt;td&gt;222&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;18. Cyclic Sort
&lt;/td&gt;
&lt;td&gt;a permutation of 1..n&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;no dedicated tag&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;19. K-way Merge
&lt;/td&gt;
&lt;td&gt;k sorted lists to combine&lt;/td&gt;
&lt;td&gt;O(n log k) time&lt;/td&gt;
&lt;td&gt;17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20. Multi-threaded
&lt;/td&gt;
&lt;td&gt;coordinate or order concurrent work&lt;/td&gt;
&lt;td&gt;depends on the coordination primitive&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The Most Common LeetCode Patterns
&lt;/h2&gt;

&lt;p&gt;If you only have time for part of this list, the eight most common LeetCode patterns are the first eight above: Two Pointers, Sliding Window, Modified Binary Search, Tree Depth First Search, Tree Breadth First Search, Island (Matrix Traversal), 0/1 Knapsack, and Top 'K' Elements.&lt;/p&gt;

&lt;p&gt;Those eight are also the most important ones to get automatic, because they are the patterns an interviewer is most likely to reach for and the ones whose variations show up across the widest range of questions. Together they account for the large majority of what gets asked in a standard coding loop.&lt;/p&gt;

&lt;p&gt;One warning about reading tag counts straight. Bitwise XOR carries 297 tagged problems, which is more than Sliding Window's 175, but almost all of those are narrow puzzles rather than interview staples. A large tag means the technique is common in the problem set, not that it is common in interviews. The order on this page accounts for that; a raw tag ranking does not.&lt;/p&gt;

&lt;h2&gt;
  
  
  LeetCode Patterns Cheat Sheet: What the Wording Tells You
&lt;/h2&gt;

&lt;p&gt;Pattern recognition is mostly vocabulary. The same phrases appear in problem statements again and again, and each one points at a small number of patterns. Use this as a lookup while you practice, then stop using it once the mapping is automatic.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;If the problem says&lt;/th&gt;
&lt;th&gt;Reach for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;"sorted array" plus "find a pair / triplet"&lt;/td&gt;
&lt;td&gt;Two Pointers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"longest" or "shortest" plus "substring" or "subarray"&lt;/td&gt;
&lt;td&gt;Sliding Window&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"at most K" or "exactly K distinct"&lt;/td&gt;
&lt;td&gt;Sliding Window&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"rotated sorted array"&lt;/td&gt;
&lt;td&gt;Modified Binary Search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"minimum / maximum value such that ..."&lt;/td&gt;
&lt;td&gt;Modified Binary Search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"root-to-leaf" or "path sum"&lt;/td&gt;
&lt;td&gt;Tree Depth First Search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"level order" or "level by level"&lt;/td&gt;
&lt;td&gt;Tree Breadth First Search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"shortest number of steps" on a graph or grid&lt;/td&gt;
&lt;td&gt;Tree Breadth First Search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"grid" plus "connected" or "regions" or "islands"&lt;/td&gt;
&lt;td&gt;Island (Matrix Traversal)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"can you partition" or "reach exactly this total"&lt;/td&gt;
&lt;td&gt;0/1 Knapsack (Dynamic Programming)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"fewest coins" or "ways to make up"&lt;/td&gt;
&lt;td&gt;0/1 Knapsack (Dynamic Programming)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"top K" or "K most frequent" or "K closest"&lt;/td&gt;
&lt;td&gt;Top 'K' Elements&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"all permutations" or "all valid boards"&lt;/td&gt;
&lt;td&gt;Backtracking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"all subsets" or "power set" or "all combinations"&lt;/td&gt;
&lt;td&gt;Subsets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"every element appears twice except one"&lt;/td&gt;
&lt;td&gt;Bitwise XOR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"cycle", "middle node", or "Nth from the end"&lt;/td&gt;
&lt;td&gt;Fast &amp;amp; Slow Pointers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"intervals", "meetings", or "time slots"&lt;/td&gt;
&lt;td&gt;Merge Intervals&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"next greater" or "next smaller" element&lt;/td&gt;
&lt;td&gt;Monotonic Stack&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"prerequisites", "course order", or "build order"&lt;/td&gt;
&lt;td&gt;Topological Sort&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"reverse the list" with O(1) extra space&lt;/td&gt;
&lt;td&gt;In-place Reversal of a Linked List&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"median" of a stream or a window&lt;/td&gt;
&lt;td&gt;Two Heaps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"numbers from 1 to n" with one missing or duplicated&lt;/td&gt;
&lt;td&gt;Cyclic Sort&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"K sorted lists" or "K sorted arrays"&lt;/td&gt;
&lt;td&gt;K-way Merge&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"threads must run in order"&lt;/td&gt;
&lt;td&gt;Multi-threaded&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two cautions. A problem can carry more than one of these signals, in which case the patterns usually compose rather than compete, such as a sliding window over a monotonic stack. And a phrase is evidence, not proof; confirm against the constraints before you commit to an approach.&lt;/p&gt;

&lt;p&gt;If you want to train this recognition rather than look it up, &lt;a href="https://www.grokkingthecodinginterview.com/blog/leetcode-patterns" rel="noopener noreferrer"&gt;this walkthrough reads a problem statement and names the pattern step by step&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two Pointers
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is sorted, or you need a pair, triplet, or subsequence that satisfies a condition.&lt;/p&gt;

&lt;p&gt;Two indices moving toward each other turn an O(n^2) scan of every pair into a single O(n) pass, because a sorted order tells you which pointer to move.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn5giwje193fmzergasz4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn5giwje193fmzergasz4.png" alt="Two Pointers pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;two_sum_sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;          &lt;span class="c1"&gt;# need a bigger sum
&lt;/span&gt;        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;          &lt;span class="c1"&gt;# need a smaller sum
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(1) space. LeetCode tags &lt;strong&gt;263&lt;/strong&gt; problems with &lt;code&gt;two-pointers&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/" rel="noopener noreferrer"&gt;Two Sum II - Input Array Is Sorted&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/3sum/" rel="noopener noreferrer"&gt;3Sum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/container-with-most-water/" rel="noopener noreferrer"&gt;Container With Most Water&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sliding Window
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the question asks for the longest, shortest, or best contiguous subarray or substring.&lt;/p&gt;

&lt;p&gt;The window expands to include new elements and contracts to restore the constraint, so each element is visited at most twice instead of being re-scanned for every start index.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5zs61jhytwpv2eh711wg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5zs61jhytwpv2eh711wg.png" alt="Sliding Window pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;longest_unique&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;      &lt;span class="c1"&gt;# contract past the duplicate
&lt;/span&gt;        &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;
        &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(k) space. LeetCode tags &lt;strong&gt;175&lt;/strong&gt; problems with &lt;code&gt;sliding-window&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/longest-substring-without-repeating-characters/" rel="noopener noreferrer"&gt;Longest Substring Without Repeating Characters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/minimum-window-substring/" rel="noopener noreferrer"&gt;Minimum Window Substring&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/maximum-average-subarray-i/" rel="noopener noreferrer"&gt;Maximum Average Subarray I&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Modified Binary Search
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is sorted or rotated, or the answer itself is a number you can test for feasibility.&lt;/p&gt;

&lt;p&gt;Any question where a candidate answer can be checked in O(n) becomes O(n log n) by binary searching the answer space rather than the array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fizrcka6maa6q4ff626x3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fizrcka6maa6q4ff626x3.png" alt="Modified Binary Search pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;search_rotated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;            &lt;span class="c1"&gt;# left half is sorted
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                &lt;span class="c1"&gt;# right half is sorted
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(log n) time, O(1) space. LeetCode tags &lt;strong&gt;356&lt;/strong&gt; problems with &lt;code&gt;binary-search&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/search-in-rotated-sorted-array/" rel="noopener noreferrer"&gt;Search in Rotated Sorted Array&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/" rel="noopener noreferrer"&gt;Find Minimum in Rotated Sorted Array&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/koko-eating-bananas/" rel="noopener noreferrer"&gt;Koko Eating Bananas&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tree Depth First Search
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the answer depends on a full root-to-leaf path, or on information returned from a subtree.&lt;/p&gt;

&lt;p&gt;Recursion carries state down the path and returns an answer back up, which is exactly the shape of path sums, depths, and subtree validity checks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs1dwkormqexigp9ei1aq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs1dwkormqexigp9ei1aq.png" alt="Tree Depth First Search pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;has_path_sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
    &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="c1"&gt;# leaf
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;has_path_sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="nf"&gt;has_path_sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(h) space. LeetCode tags &lt;strong&gt;349&lt;/strong&gt; problems with &lt;code&gt;depth-first-search&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/maximum-depth-of-binary-tree/" rel="noopener noreferrer"&gt;Maximum Depth of Binary Tree&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/path-sum/" rel="noopener noreferrer"&gt;Path Sum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/validate-binary-search-tree/" rel="noopener noreferrer"&gt;Validate Binary Search Tree&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tree Breadth First Search
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the question mentions levels, or asks for the shortest number of steps.&lt;/p&gt;

&lt;p&gt;A queue visits every node at distance k before any node at distance k+1, so the first time you reach a target you have reached it by the shortest route.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqlqfxx8lfcl35owkey3q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqlqfxx8lfcl35owkey3q.png" alt="Tree Breadth First Search pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;deque&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;level_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="nf"&gt;deque&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;              &lt;span class="c1"&gt;# freeze the level width
&lt;/span&gt;            &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;popleft&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(w) space. LeetCode tags &lt;strong&gt;260&lt;/strong&gt; problems with &lt;code&gt;breadth-first-search&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/binary-tree-level-order-traversal/" rel="noopener noreferrer"&gt;Binary Tree Level Order Traversal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/" rel="noopener noreferrer"&gt;Binary Tree Zigzag Level Order Traversal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/minimum-depth-of-binary-tree/" rel="noopener noreferrer"&gt;Minimum Depth of Binary Tree&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Island (Matrix Traversal)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is a grid and you need to find or count connected regions.&lt;/p&gt;

&lt;p&gt;A grid is a graph whose neighbors are implicit, so one flood fill per unvisited cell counts regions in a single pass over the matrix.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F59g0frlilbx7zkayori3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F59g0frlilbx7zkayori3.png" alt="Island (Matrix Traversal) pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;num_islands&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cols&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;cols&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;
        &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;                     &lt;span class="c1"&gt;# mark visited in place
&lt;/span&gt;        &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cols&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
                &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(m*n) time, O(m*n) space. LeetCode tags &lt;strong&gt;285&lt;/strong&gt; problems with &lt;code&gt;matrix&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/number-of-islands/" rel="noopener noreferrer"&gt;Number of Islands&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/max-area-of-island/" rel="noopener noreferrer"&gt;Max Area of Island&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/surrounded-regions/" rel="noopener noreferrer"&gt;Surrounded Regions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  0/1 Knapsack (Dynamic Programming)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you must choose a subset under a capacity or budget, and subproblems repeat.&lt;/p&gt;

&lt;p&gt;Each item is either taken or skipped, so the answer for a capacity depends only on smaller capacities, which a table fills once instead of re-deriving exponentially.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc7o34m6houkwa0odfuk5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc7o34m6houkwa0odfuk5.png" alt="0/1 Knapsack (Dynamic Programming) pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;can_partition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
    &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
    &lt;span class="n"&gt;dp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;cap&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;   &lt;span class="c1"&gt;# backwards: each item once
&lt;/span&gt;            &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cap&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n*C) time, O(C) space. LeetCode tags &lt;strong&gt;684&lt;/strong&gt; problems with &lt;code&gt;dynamic-programming&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/partition-equal-subset-sum/" rel="noopener noreferrer"&gt;Partition Equal Subset Sum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/coin-change/" rel="noopener noreferrer"&gt;Coin Change&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/target-sum/" rel="noopener noreferrer"&gt;Target Sum&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Top 'K' Elements
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the question asks for the k largest, k smallest, k most frequent, or k closest.&lt;/p&gt;

&lt;p&gt;A heap of size k keeps only the candidates that can still win, which costs O(n log k) instead of the O(n log n) of sorting everything.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffmq44i3tet1hk3kkjin4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffmq44i3tet1hk3kkjin4.png" alt="Top 'K' Elements pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;heapq&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;kth_largest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;              &lt;span class="c1"&gt;# drop the smallest candidate
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n log k) time, O(k) space. LeetCode tags &lt;strong&gt;222&lt;/strong&gt; problems with &lt;code&gt;heap-priority-queue&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/kth-largest-element-in-an-array/" rel="noopener noreferrer"&gt;Kth Largest Element in an Array&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/top-k-frequent-elements/" rel="noopener noreferrer"&gt;Top K Frequent Elements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/k-closest-points-to-origin/" rel="noopener noreferrer"&gt;K Closest Points to Origin&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Backtracking
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the question asks for all valid configurations, not just a count or a best one.&lt;/p&gt;

&lt;p&gt;You build a candidate one choice at a time and undo the choice on the way out, which explores the whole space while holding only one path in memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbzb2vp0ggs3qv7p7pydp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbzb2vp0ggs3qv7p7pydp.png" alt="Backtracking pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;permute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;[:])&lt;/span&gt;              &lt;span class="c1"&gt;# copy, the path mutates
&lt;/span&gt;            &lt;span class="k"&gt;return&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;      &lt;span class="c1"&gt;# undo
&lt;/span&gt;    &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(b^d) time, O(d) space. LeetCode tags &lt;strong&gt;114&lt;/strong&gt; problems with &lt;code&gt;backtracking&lt;/code&gt;, and it shares the backtracking tag with Subsets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/permutations/" rel="noopener noreferrer"&gt;Permutations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/n-queens/" rel="noopener noreferrer"&gt;N-Queens&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/word-search/" rel="noopener noreferrer"&gt;Word Search&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Subsets
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you need every combination, subset, or power set of the input.&lt;/p&gt;

&lt;p&gt;Each element is in or out, so the answer set doubles per element, and you can build it iteratively by cloning what you already have.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5bm86mvcqzdnw73mcvcj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5bm86mvcqzdnw73mcvcj.png" alt="Subsets pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;subsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[]]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;    &lt;span class="c1"&gt;# clone everything, add n
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n * 2^n) time, O(n * 2^n) space. LeetCode tags &lt;strong&gt;114&lt;/strong&gt; problems with &lt;code&gt;backtracking&lt;/code&gt;, and it shares the backtracking tag with Backtracking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/subsets/" rel="noopener noreferrer"&gt;Subsets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/subsets-ii/" rel="noopener noreferrer"&gt;Subsets II&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/letter-combinations-of-a-phone-number/" rel="noopener noreferrer"&gt;Letter Combinations of a Phone Number&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Bitwise XOR
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; elements pair up and cancel, or you are asked to find a single missing or unique value.&lt;/p&gt;

&lt;p&gt;XOR of a value with itself is zero and XOR is order independent, so every duplicate cancels and the lone survivor is the answer in O(1) space.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk7bs3qc1tq79k0oafmbn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk7bs3qc1tq79k0oafmbn.png" alt="Bitwise XOR pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;single_number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;^=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;                             &lt;span class="c1"&gt;# pairs cancel to 0
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(1) space. LeetCode tags &lt;strong&gt;297&lt;/strong&gt; problems with &lt;code&gt;bit-manipulation&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/single-number/" rel="noopener noreferrer"&gt;Single Number&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/missing-number/" rel="noopener noreferrer"&gt;Missing Number&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/find-the-duplicate-number/" rel="noopener noreferrer"&gt;Find the Duplicate Number&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Fast &amp;amp; Slow Pointers
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is a linked list or an implicit sequence, and you need a cycle, a middle, or a kth-from-end node.&lt;/p&gt;

&lt;p&gt;Two pointers at different speeds meet inside a cycle and land the slow one at the middle on a straight run, with no extra memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq61l2z27thpciyxvwuev.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq61l2z27thpciyxvwuev.png" alt="Fast &amp;amp; Slow Pointers pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;has_cycle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;slow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fast&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;head&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;fast&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;fast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;slow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;slow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;                     &lt;span class="c1"&gt;# one step
&lt;/span&gt;        &lt;span class="n"&gt;fast&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;                &lt;span class="c1"&gt;# two steps
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;slow&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;fast&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(1) space. LeetCode tags &lt;strong&gt;263&lt;/strong&gt; problems with &lt;code&gt;two-pointers&lt;/code&gt;, and it shares the two-pointers tag with Two Pointers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/linked-list-cycle/" rel="noopener noreferrer"&gt;Linked List Cycle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/middle-of-the-linked-list/" rel="noopener noreferrer"&gt;Middle of the Linked List&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/happy-number/" rel="noopener noreferrer"&gt;Happy Number&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Merge Intervals
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is a list of ranges, meetings, or time slots that may overlap.&lt;/p&gt;

&lt;p&gt;Once intervals are sorted by start, every overlap is adjacent, so one pass merges or counts them without comparing all pairs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fv3ig0elbis0uey4gw9j8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fv3ig0elbis0uey4gw9j8.png" alt="Merge Intervals pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;intervals&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;intervals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;iv&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;iv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;intervals&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;      &lt;span class="c1"&gt;# overlaps the previous
&lt;/span&gt;            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n log n) time, O(n) space. LeetCode has no dedicated tag for this one; these sit under array and sorting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/merge-intervals/" rel="noopener noreferrer"&gt;Merge Intervals&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/insert-interval/" rel="noopener noreferrer"&gt;Insert Interval&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/non-overlapping-intervals/" rel="noopener noreferrer"&gt;Non-overlapping Intervals&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Monotonic Stack
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you need the next greater or next smaller element, or the span a value dominates.&lt;/p&gt;

&lt;p&gt;A stack kept in sorted order discards elements that can never be an answer again, so every element is pushed and popped at most once.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F81dbkercuxvoeoi9exdl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F81dbkercuxvoeoi9exdl.png" alt="Monotonic Stack pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;daily_temperatures&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;temps&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;temps&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;        &lt;span class="c1"&gt;# stack holds indices
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;temps&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;temps&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;
        &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(n) space. LeetCode tags &lt;strong&gt;76&lt;/strong&gt; problems with &lt;code&gt;monotonic-stack&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/next-greater-element-i/" rel="noopener noreferrer"&gt;Next Greater Element I&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/daily-temperatures/" rel="noopener noreferrer"&gt;Daily Temperatures&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/largest-rectangle-in-histogram/" rel="noopener noreferrer"&gt;Largest Rectangle in Histogram&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Topological Sort
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; tasks, courses, or builds have prerequisites, and you need a valid order or a cycle check.&lt;/p&gt;

&lt;p&gt;Repeatedly removing nodes with no remaining prerequisites produces a legal order, and a leftover node proves a cycle exists.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F48yknse4eosqm7ca49ki.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F48yknse4eosqm7ca49ki.png" alt="Topological Sort pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;deque&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;find_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prereqs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indeg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;course&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;need&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;prereqs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;need&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;course&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;indeg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;course&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deque&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;indeg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;popleft&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;nxt&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
            &lt;span class="n"&gt;indeg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;nxt&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;indeg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;nxt&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nxt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;      &lt;span class="c1"&gt;# short means a cycle
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(V+E) time, O(V+E) space. LeetCode tags &lt;strong&gt;40&lt;/strong&gt; problems with &lt;code&gt;topological-sort&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/course-schedule/" rel="noopener noreferrer"&gt;Course Schedule&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/course-schedule-ii/" rel="noopener noreferrer"&gt;Course Schedule II&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/minimum-height-trees/" rel="noopener noreferrer"&gt;Minimum Height Trees&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  In-place Reversal of a Linked List
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you must reverse a list or a sublist without allocating a new one.&lt;/p&gt;

&lt;p&gt;Rewiring the next pointer of each node as you walk reverses the list in one pass and O(1) extra space.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx1zr7ysr4hlnwzohnfpp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx1zr7ysr4hlnwzohnfpp.png" alt="In-place Reversal of a Linked List pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;reverse_list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;head&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;nxt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;                       &lt;span class="c1"&gt;# save before overwriting
&lt;/span&gt;        &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prev&lt;/span&gt;
        &lt;span class="n"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nxt&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;prev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(1) space. LeetCode tags &lt;strong&gt;82&lt;/strong&gt; problems with &lt;code&gt;linked-list&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/reverse-linked-list/" rel="noopener noreferrer"&gt;Reverse Linked List&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/reverse-linked-list-ii/" rel="noopener noreferrer"&gt;Reverse Linked List II&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/reverse-nodes-in-k-group/" rel="noopener noreferrer"&gt;Reverse Nodes in k-Group&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Two Heaps
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you need a running median, or to keep a set split into a smaller half and a larger half.&lt;/p&gt;

&lt;p&gt;A max-heap over the low half and a min-heap over the high half put the middle value at the two tops, so the median is O(1) to read.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpdh697xlipxlqy7w8atk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpdh697xlipxlqy7w8atk.png" alt="Two Heaps pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;heapq&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MedianFinder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;         &lt;span class="c1"&gt;# low is a max-heap (negated)
&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;median&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="nf"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(log n) insert, O(1) median. LeetCode tags &lt;strong&gt;222&lt;/strong&gt; problems with &lt;code&gt;heap-priority-queue&lt;/code&gt;, and it shares the heap tag with Top 'K' Elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/find-median-from-data-stream/" rel="noopener noreferrer"&gt;Find Median from Data Stream&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/sliding-window-median/" rel="noopener noreferrer"&gt;Sliding Window Median&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/ipo/" rel="noopener noreferrer"&gt;IPO&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cyclic Sort
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is a permutation of numbers in a known range such as 1 to n.&lt;/p&gt;

&lt;p&gt;When a value implies its own index, swapping each number home sorts the array in O(n) with no extra space, which exposes missing and duplicate values.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvtvwh7dyi5zza59u5x7u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvtvwh7dyi5zza59u5x7u.png" alt="Cyclic Sort pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;cyclic_sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;home&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;                   &lt;span class="c1"&gt;# value n belongs at index n-1
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;home&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
            &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(1) space. LeetCode has no dedicated tag for this one; these sit under array and sorting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/missing-number/" rel="noopener noreferrer"&gt;Missing Number&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/" rel="noopener noreferrer"&gt;Find All Numbers Disappeared in an Array&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/first-missing-positive/" rel="noopener noreferrer"&gt;First Missing Positive&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  K-way Merge
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you are given k sorted lists, arrays, or streams to combine or search across.&lt;/p&gt;

&lt;p&gt;A heap holding one candidate from each list always exposes the global smallest next element, so the merge costs O(n log k).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7e3jwm7i0yvkvc01y0vi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7e3jwm7i0yvkvc01y0vi.png" alt="K-way Merge pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;heapq&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;merge_k_sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lists&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lst&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lists&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heapify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lists&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt;         &lt;span class="c1"&gt;# refill from the same list
&lt;/span&gt;            &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lists&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n log k) time, O(k) space. LeetCode tags &lt;strong&gt;17&lt;/strong&gt; problems with &lt;code&gt;merge-sort&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/merge-k-sorted-lists/" rel="noopener noreferrer"&gt;Merge k Sorted Lists&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/" rel="noopener noreferrer"&gt;Kth Smallest Element in a Sorted Matrix&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/find-k-pairs-with-smallest-sums/" rel="noopener noreferrer"&gt;Find K Pairs with Smallest Sums&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Multi-threaded
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the question asks you to coordinate concurrent work, or to enforce an order between threads.&lt;/p&gt;

&lt;p&gt;The algorithm is usually trivial; what is graded is whether you reach for the right primitive and avoid a race or a deadlock.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx8k53ci8oxph6jaubt3p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx8k53ci8oxph6jaubt3p.png" alt="Multi-threaded pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Foo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;second&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Semaphore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;third&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Semaphore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;printFirst&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;printFirst&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;second&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;release&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;                &lt;span class="c1"&gt;# unblock the next stage
&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;second_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;printSecond&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;second&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;acquire&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;printSecond&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;third&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;release&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;third_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;printThird&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;third&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;acquire&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;printThird&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; depends on the coordination primitive. LeetCode tags &lt;strong&gt;9&lt;/strong&gt; problems with &lt;code&gt;concurrency&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/print-in-order/" rel="noopener noreferrer"&gt;Print in Order&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/print-foobar-alternately/" rel="noopener noreferrer"&gt;Print FooBar Alternately&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/building-h2o/" rel="noopener noreferrer"&gt;Building H2O&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Which LeetCode Patterns Are Most Important
&lt;/h2&gt;

&lt;p&gt;This is the part most pattern lists leave out. Not every pattern earns the same return, because LeetCode's own problems are not evenly spread across them.&lt;/p&gt;

&lt;p&gt;Every question on LeetCode carries one or more topic tags. Counting those tags shows where the problems actually are, which is a better guide to study order than any opinion. Here are the 20 largest tags across the 4,073 problems.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;LeetCode topic tag&lt;/th&gt;
&lt;th&gt;Problems&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Array&lt;/td&gt;
&lt;td&gt;2273&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;String&lt;/td&gt;
&lt;td&gt;895&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hash Table&lt;/td&gt;
&lt;td&gt;843&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dynamic Programming&lt;/td&gt;
&lt;td&gt;684&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sorting&lt;/td&gt;
&lt;td&gt;540&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Greedy&lt;/td&gt;
&lt;td&gt;483&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Binary Search&lt;/td&gt;
&lt;td&gt;356&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Depth-First Search&lt;/td&gt;
&lt;td&gt;349&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bit Manipulation&lt;/td&gt;
&lt;td&gt;297&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Matrix&lt;/td&gt;
&lt;td&gt;285&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prefix Sum&lt;/td&gt;
&lt;td&gt;277&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tree&lt;/td&gt;
&lt;td&gt;270&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Two Pointers&lt;/td&gt;
&lt;td&gt;263&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Breadth-First Search&lt;/td&gt;
&lt;td&gt;260&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Heap (Priority Queue)&lt;/td&gt;
&lt;td&gt;222&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Graph&lt;/td&gt;
&lt;td&gt;190&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stack&lt;/td&gt;
&lt;td&gt;182&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sliding Window&lt;/td&gt;
&lt;td&gt;175&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backtracking&lt;/td&gt;
&lt;td&gt;114&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Union Find&lt;/td&gt;
&lt;td&gt;98&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things follow from this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Array, String, and Hash Table are not patterns, they are the surface.&lt;/strong&gt; They head the list because almost everything is phrased in terms of them. What matters is the technique applied to them, which is why Two Pointers and Sliding Window carry so much weight despite smaller tag counts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A small set of patterns covers most of the volume.&lt;/strong&gt; Two Pointers, Sliding Window, Modified Binary Search, the two tree traversals, and Dynamic Programming together account for more tagged problems than the rest of this list combined. If your preparation time is short, those are the ones to install first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The long tail is still worth knowing, but last.&lt;/strong&gt; K-way Merge has 17 tagged problems and Multi-threaded has 9. They are rare, and they are also the ones candidates most often have no answer for. Learn them when the common patterns are automatic, not before.&lt;/p&gt;

&lt;h2&gt;
  
  
  How This Compares With the Other LeetCode Pattern Lists
&lt;/h2&gt;

&lt;p&gt;Three resources come up whenever people look for this, and they are all worth knowing about. They do different jobs, and two of them are free.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sean Prashad's Leetcode Patterns
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://seanprashad.com/leetcode-patterns/" rel="noopener noreferrer"&gt;seanprashad.com/leetcode-patterns&lt;/a&gt; is a free, open source list, and it is the most widely used of the three. Its repository describes it as "a pattern-based approach to learn technical interview questions" and carries 14,117 stars.&lt;/p&gt;

&lt;p&gt;What it gives you is a curated set of &lt;strong&gt;179 problems&lt;/strong&gt; you can filter by difficulty, by company, and by pattern, plus a condition-to-approach table that maps a problem characteristic to a suggested technique. It is excellent for deciding what to solve next, and for working a company-specific list before an onsite.&lt;/p&gt;

&lt;p&gt;What it does not do is teach the patterns. The labels it sorts by are mostly LeetCode's own topic tags, around 75 of them, so "Array" and "Hash Table" sit alongside "Sliding Window". If you already know the patterns, that is exactly what you want. If you are trying to learn them, a list cannot explain why a window contracts or when binary search applies to an answer rather than an array.&lt;/p&gt;

&lt;h3&gt;
  
  
  AlgoMaster's 15 Patterns
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://blog.algomaster.io/p/15-leetcode-patterns" rel="noopener noreferrer"&gt;AlgoMaster's post&lt;/a&gt; covers 15 patterns, each with a diagram, a one-line note on when to use it, and three linked LeetCode problems. It is well made and it is the piece most people have read on this topic.&lt;/p&gt;

&lt;p&gt;It stops short of code. There is no template for any of the 15, so you get the idea of a pattern without the implementation you would actually write under time pressure.&lt;/p&gt;

&lt;h3&gt;
  
  
  NeetCode
&lt;/h3&gt;

&lt;p&gt;NeetCode is a roadmap built around curated problem lists with solution walkthroughs, and it is the strongest option if you prefer to learn by watching rather than reading. We cover it separately rather than summarize it here: &lt;a href="https://www.grokkingthecodinginterview.com/blog/neetcode-roadmap" rel="noopener noreferrer"&gt;the NeetCode roadmap on one page&lt;/a&gt; maps the pattern behind each topic, and &lt;a href="https://www.grokkingthecodinginterview.com/blog/neetcode-vs-leetcode" rel="noopener noreferrer"&gt;NeetCode compared with LeetCode&lt;/a&gt; puts the numbers side by side.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where this page fits
&lt;/h3&gt;

&lt;p&gt;This one is the explained version. Every pattern gets the cue that identifies it, why the technique works, a template in Python, a diagram, and three problems, so you can go from never having seen a pattern to writing it from memory without leaving the page.&lt;/p&gt;

&lt;p&gt;Use whichever fits what you need right now. If you want a filterable queue of problems, use Sean Prashad's list. If you want video, use NeetCode. If you want to understand the 20 patterns well enough to recognize them on a question you have never seen, read this page and then practice against one of those lists. They work well together, and a free list plus a real explanation beats either on its own.&lt;/p&gt;

&lt;p&gt;For a wider view of the paid and free options, including the video courses, see &lt;a href="https://www.grokkingthecodinginterview.com/blog/best-dsa-courses" rel="noopener noreferrer"&gt;the best DSA courses compared&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Use This List
&lt;/h2&gt;

&lt;p&gt;Work one pattern at a time rather than one problem at a time. Read the cue, write the template from memory, then solve the three linked problems in a row. Practicing LeetCode problems pattern wise, meaning grouped by the pattern that solves them rather than in list order, teaches you more than solving ten unrelated ones, because the third problem in a group is where recognition starts to happen on its own.&lt;/p&gt;

&lt;p&gt;That is why the 60 problems on this page are grouped under their pattern instead of being given as one flat list. A flat list trains you to grind. Problems grouped by pattern train you to recognize.&lt;/p&gt;

&lt;p&gt;When a problem defeats you, do not jump straight to the solution. Ask which of these 20 it resembles first. If you can name the pattern and still cannot finish, that is a template problem and it is quick to fix. If you cannot name the pattern at all, that is the skill actually being tested, and it is the one worth practicing.&lt;/p&gt;

&lt;p&gt;The full curriculum, with each pattern taught in six languages and grouped practice problems, is in &lt;a href="https://www.designgurus.io/course/grokking-the-coding-interview?utm_source=devto" rel="noopener noreferrer"&gt;Grokking the Coding Interview&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Check out &lt;a href="https://www.designgurus.io/blind75?utm_source=devto" rel="noopener noreferrer"&gt;Blind75&lt;/a&gt; for more problems. If you are choosing a course to learn these patterns from, &lt;a href="https://www.grokkingthecodinginterview.com/blog/best-dsa-courses" rel="noopener noreferrer"&gt;The Best DSA Courses Compared: Paid, Free, and YouTube&lt;/a&gt; reviews the main options side by side.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQs - LeetCode Patterns and Interview Prep
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Q1. What are LeetCode patterns?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;LeetCode patterns&lt;/strong&gt; are common coding techniques or strategies that repeatedly show up in LeetCode problems and technical interviews. Instead of solving every problem from scratch, learning these patterns helps you recognize how to approach and solve new problems based on familiar logic (e.g., Two Pointers, Sliding Window, DFS, etc.).&lt;/p&gt;

&lt;h3&gt;
  
  
  Q2. Why should I learn LeetCode patterns instead of solving random problems?
&lt;/h3&gt;

&lt;p&gt;Focusing on patterns helps you avoid burnout and prepares you faster. Each pattern unlocks the ability to solve dozens of problems, which is much more efficient than solving 500+ random questions without structure. Interviewers often test your ability to apply known patterns to new scenarios, not just memorize solutions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q3. How many LeetCode patterns should I learn for FAANG interviews?
&lt;/h3&gt;

&lt;p&gt;Learn all &lt;strong&gt;20&lt;/strong&gt;, in the order on this page. The first six, Two Pointers, Sliding Window, Modified Binary Search, the two tree traversals, and Dynamic Programming, cover the largest share of what gets asked, so start there if your time is short. The remaining fourteen are what separate a candidate who handles the common question from one who is not stopped by an unusual one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q4. Do LeetCode patterns actually help in real interviews?
&lt;/h3&gt;

&lt;p&gt;Yes, most FAANG interview questions map to well-known patterns. Recognizing the right pattern during an interview helps you solve problems faster and with more confidence, especially under time pressure. It also shows your structured thinking, which is exactly what interviewers want.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q5. Where can I practice LeetCode patterns?
&lt;/h3&gt;

&lt;p&gt;You can start with categorized problem lists on LeetCode itself, or check out structured resources like &lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-the-coding-interview?utm_source=devto" rel="noopener noreferrer"&gt;Grokking the Coding Interview&lt;/a&gt;&lt;/strong&gt;, which teaches these patterns with guided explanations and practice problems grouped by pattern.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q6. Are LeetCode patterns the same as algorithms?
&lt;/h3&gt;

&lt;p&gt;Not exactly. Algorithms are step-by-step procedures for solving specific types of problems (like Dijkstra’s or Merge Sort). &lt;strong&gt;Patterns&lt;/strong&gt; are reusable problem-solving approaches, like frameworks, that help you decide &lt;em&gt;how&lt;/em&gt; to apply different algorithms or data structures depending on the question.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q7. How do I identify which pattern a question belongs to?
&lt;/h3&gt;

&lt;p&gt;Look at the problem constraints and the goal. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Need to find a subarray or substring? → Try &lt;strong&gt;Sliding Window&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Working with sorted data or binary decisions? → Use &lt;strong&gt;Binary Search&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Need to explore all paths or combinations? → Think &lt;strong&gt;DFS&lt;/strong&gt; or &lt;strong&gt;Backtracking&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The more patterns you practice, the easier it becomes to recognize which one fits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q8. Is mastering patterns enough to crack coding interviews?
&lt;/h3&gt;

&lt;p&gt;Patterns are your foundation, but combine them with good communication, mock interviews, and time management. You should also review system design (for senior roles), &lt;a href="https://www.designgurus.io/blog/tech-interview-behavioral-questions?utm_source=devto" rel="noopener noreferrer"&gt;behavioral interview questions&lt;/a&gt;, and understand the company’s specific process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q9. What are the best LeetCode patterns to know?
&lt;/h3&gt;

&lt;p&gt;The best LeetCode patterns to focus on are the ones that appear most frequently in coding interviews and help solve a wide variety of problems. These include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Two Pointers&lt;/strong&gt; – great for arrays and strings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sliding Window&lt;/strong&gt; – ideal for subarray/substring problems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Depth-First Search (DFS)&lt;/strong&gt; – for tree and graph traversal&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Breadth-First Search (BFS)&lt;/strong&gt; – used in shortest path and level order problems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Binary Search&lt;/strong&gt; – for problems with sorted data or monotonic conditions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Merge Intervals&lt;/strong&gt; – useful in scheduling and overlapping intervals&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic Programming (DP)&lt;/strong&gt; – for optimization and counting problems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recursion &amp;amp; Backtracking&lt;/strong&gt; – perfect for exhaustive search and decision trees&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monotonic Stack&lt;/strong&gt; – for next greater/smaller element problems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Union-Find (DSU)&lt;/strong&gt; – for detecting cycles and grouping connected components&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mastering these patterns allows you to recognize problem types quickly and apply efficient solutions, critical for success in FAANG interviews.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q10. Why study coding patterns for interviews?
&lt;/h3&gt;

&lt;p&gt;Studying coding patterns helps you avoid random practice and prepare more strategically. Instead of solving every problem from scratch, patterns teach you how to &lt;strong&gt;recognize the underlying structure&lt;/strong&gt; of a problem and &lt;strong&gt;reuse proven techniques&lt;/strong&gt;. This saves time, builds confidence, and dramatically improves your problem-solving skills.&lt;/p&gt;

&lt;p&gt;Most interview problems are variations of core patterns. &lt;/p&gt;

&lt;p&gt;By mastering them, you’ll be able to tackle new problems more quickly, reduce anxiety during live interviews, and demonstrate structured thinking, something interviewers love to see. In short, patterns are the shortcut to smarter and faster coding interview prep.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Go deeper:&lt;/strong&gt; for the expanded version of this pattern-first approach, see the &lt;a href="https://www.grokkingthecodinginterview.com/blog/leetcode-patterns" rel="noopener noreferrer"&gt;complete guide to all 42 coding interview patterns&lt;/a&gt;, which includes the tell that identifies each pattern from the problem statement, a printable cheat sheet, and free pattern-by-pattern deep dives.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q11. How many LeetCode patterns are there?
&lt;/h3&gt;

&lt;p&gt;There is no official count, because LeetCode does not publish one. This guide uses &lt;strong&gt;20&lt;/strong&gt;, which is the set that covers the overwhelming majority of interview questions without padding the list. Other lists quote 14, 15, or 23; the differences are mostly about whether closely related techniques are split apart or grouped together, not about the underlying ideas.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q12. Are LeetCode patterns the same as design patterns or pattern matching?
&lt;/h3&gt;

&lt;p&gt;No, and the three get confused often.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Design patterns&lt;/strong&gt; are object-oriented structures such as Singleton, Factory, and Observer. They belong to object-oriented design and low level design rounds, not to the algorithmic patterns on this page. LeetCode does have a separate &lt;strong&gt;Design&lt;/strong&gt; tag, with 134 problems like LRU Cache and Design Twitter, which asks you to build a data structure to a specification. That is a different skill again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pattern matching&lt;/strong&gt; means string matching, regular expressions, and problems like Regular Expression Matching or Wildcard Matching. It is a problem topic, not a solving strategy.&lt;/p&gt;

&lt;p&gt;The 20 on this page are &lt;strong&gt;coding patterns&lt;/strong&gt;, also called DSA patterns: reusable strategies for recognizing and solving algorithm questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related questions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/which-is-better-codechef-or-leetcode-or-hackerrank"&gt;Which is better CodeChef or LeetCode or HackerRank?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/how-many-leetcode-problems-should-i-do-per-day"&gt;How many LeetCode problems should I do per day?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/what-is-a-good-rank-on-leetcode"&gt;What is a good rank on LeetCode?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/how-much-leetcode-is-enough-for-google"&gt;How much LeetCode is enough for Google?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/do-faang-companies-ask-leetcode-hard"&gt;Do Faang companies ask LeetCode hard?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/what-is-a-good-acceptance-rate-on-leetcode"&gt;What is a good acceptance rate on LeetCode?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/what-is-the-most-used-language-on-leetcode"&gt;What is the most used language on LeetCode?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://www.designgurus.io/blog/top-lc-patterns?utm_source=devto" rel="noopener noreferrer"&gt;DesignGurus.io&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>algorithms</category>
      <category>interview</category>
      <category>programming</category>
    </item>
    <item>
      <title>System Design Patterns: The Complete Guide (60+ Patterns Explained Simply)</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Sun, 19 Jul 2026 06:41:18 +0000</pubDate>
      <link>https://dev.to/arslan_ah/system-design-patterns-the-complete-guide-60-patterns-explained-simply-1ckk</link>
      <guid>https://dev.to/arslan_ah/system-design-patterns-the-complete-guide-60-patterns-explained-simply-1ckk</guid>
      <description>&lt;p&gt;Every system you admire is built from parts you can name. The feed that loads in 80 milliseconds, the checkout that survives a datacenter failure, the chatbot that answers from yesterday's documentation: each one is a composition of the same recurring solutions, applied in the right places. Those recurring solutions are &lt;strong&gt;system design patterns&lt;/strong&gt;, and there are roughly sixty of them worth knowing.&lt;/p&gt;

&lt;p&gt;This guide covers all of them. For each pattern you will get three things: the problem it solves, the core move it makes, and the price you pay for using it. By the end, you should be able to look at any architecture, or any interview prompt, and see the parts.&lt;/p&gt;

&lt;p&gt;📚 &lt;strong&gt;Related:&lt;/strong&gt; &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-in-2027-the-best-resources-in-the-order-you-should-use-them-1i94"&gt;How to Learn System Design in 2027: The Best Resources, in the Order You Should Use Them&lt;/a&gt;, a stage-by-stage path with 20 resources and a 10-week plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What Are System Design Patterns?
&lt;/h2&gt;

&lt;p&gt;A system design pattern is a named, reusable solution to a problem that recurs when you build distributed systems. "Reads are overwhelming my database" is a recurring problem; &lt;strong&gt;primary-replica replication&lt;/strong&gt; is its named solution. "A retry charged the customer twice" is a recurring problem; &lt;strong&gt;idempotency&lt;/strong&gt; is its named solution.&lt;/p&gt;

&lt;p&gt;Two clarifications before we start.&lt;/p&gt;

&lt;p&gt;First, system design patterns are not the same as the classic "design patterns" from the Gang of Four book. Those are code-level patterns (Singleton, Observer, Factory) for organizing classes inside one program. System design patterns are architecture-level: they describe how databases, queues, caches, and services work together across many machines. In a system design interview, the interviewer means the architecture-level kind.&lt;/p&gt;

&lt;p&gt;Second, a pattern is not a technology. Kafka is a product; the &lt;strong&gt;message queue&lt;/strong&gt; and the &lt;strong&gt;append-only log&lt;/strong&gt; are the patterns inside it. Redis is a product; &lt;strong&gt;cache-aside&lt;/strong&gt; is the pattern you use it for. Learn the pattern and you can evaluate any product. Learn only the product and you are lost when the stack changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Why Patterns Beat Memorizing Architectures
&lt;/h2&gt;

&lt;p&gt;There are thousands of possible system designs, and you cannot memorize them all. You do not need to. Architectures are sentences; patterns are the words. Once you own the vocabulary, "design Instagram" stops being a memory test and becomes a composition exercise.&lt;/p&gt;

&lt;p&gt;Working with patterns is three habits:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Diagnosis.&lt;/strong&gt; Recognize which problem you are actually looking at. Dashboards are green but one feature is starving: that is the bulkhead problem. Two teams' metrics disagree: that is the same question with two authors. Most of system design skill is matching symptoms to shapes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Composition.&lt;/strong&gt; Combine patterns, and handle the seams between them. Retries demand idempotency. Caches demand a stampede plan. Sagas demand designed compensations. The seams are where real engineering lives.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pricing.&lt;/strong&gt; Every pattern is a purchase. Sharding buys write scale and costs you cross-shard queries. Caching buys speed and costs you staleness. Saying the cost out loud, in the same breath as the pattern, is what separates senior answers from buzzword answers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep those three habits in mind as you read the catalog below. Each entry is deliberately structured as diagnosis (the problem), composition material (the move), and price (the cost).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(I teach all sixty of these patterns in depth, each one through a real production incident, in my course &lt;a href="https://www.designgurus.io/course/system-design-patterns?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=sdp-cluster&amp;amp;utm_content=system-design-patterns-complete-guide" rel="noopener noreferrer"&gt;System Design Patterns: From Fundamentals to Real Systems&lt;/a&gt;. This guide is the map; the course is the territory.)&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The Complete List: 60+ System Design Patterns by Category
&lt;/h2&gt;

&lt;p&gt;The patterns fall into ten categories. Use the list below to jump around, or read straight through: the order follows how problems actually arrive as a system grows.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Communication patterns (7)&lt;/li&gt;
&lt;li&gt;Storage and replication patterns (6)&lt;/li&gt;
&lt;li&gt;Caching patterns (5)&lt;/li&gt;
&lt;li&gt;Reliability patterns (7)&lt;/li&gt;
&lt;li&gt;Scaling patterns (5)&lt;/li&gt;
&lt;li&gt;Consistency patterns (4)&lt;/li&gt;
&lt;li&gt;API and edge patterns (9)&lt;/li&gt;
&lt;li&gt;Operations and delivery patterns (5)&lt;/li&gt;
&lt;li&gt;Data-intensive patterns (7)&lt;/li&gt;
&lt;li&gt;AI-era patterns (7)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fktifelms1rsc0n9zmr9h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fktifelms1rsc0n9zmr9h.png" alt="The System Design Pattern Map: 60+ patterns in ten categories" width="799" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Communication Patterns: Moving Data Between Services
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Request-Response.&lt;/strong&gt; The default: a client asks, a server answers, someone waits. It is the right choice whenever a user is waiting for the answer. Its weakness is coupling: the caller's fate is tied to the callee's speed and health, which is why half the reliability patterns below exist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Message Queue.&lt;/strong&gt; Work that nobody needs to wait on goes into a queue, and workers process it at their own pace. Traffic spikes become backlog instead of outages. The price: delivery is at-least-once, so consumers must handle duplicates, and the queue's depth becomes a metric you must watch. Which broker you pick matters too: see &lt;a href="https://www.designgurus.io/blog/kafka-vs-rabbitmq" rel="noopener noreferrer"&gt;Kafka vs RabbitMQ: Log vs Queue, and How to Choose&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Publish-Subscribe.&lt;/strong&gt; One event, many independent consumers. The order service announces "order placed" once; email, analytics, and inventory each react without knowing about each other. The price: your event schema becomes a public contract, and changing it becomes a negotiation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Event-Driven Architecture.&lt;/strong&gt; The pub-sub idea promoted to an architectural style: services react to facts instead of calling each other. You gain loose coupling and independent scaling. You pay in governance: who consumes what, and how a business flow is traced across five reacting services. For a full walkthrough, see &lt;a href="https://www.designgurus.io/blog/event-driven-architecture" rel="noopener noreferrer"&gt;Event-Driven Architecture: Patterns, Diagrams, and When to Use It Over Request-Response&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Webhooks.&lt;/strong&gt; Events delivered across company boundaries as HTTP POSTs. The receiving discipline: verify the signature, save the raw event, respond in milliseconds, process later behind your own queue, and reconcile with a polling loop, because the worst webhook failure looks exactly like a quiet day.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server-Sent Events (SSE).&lt;/strong&gt; One HTTP response that never ends: the server pushes updates down it as they happen. It is why LLM chat apps show words one at a time. One direction only, and the browser handles reconnection for you. When the client needs to talk back continuously, you have outgrown it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bidirectional Streaming (WebSockets).&lt;/strong&gt; A true two-way conversation on one connection: chat, collaborative editing, multiplayer games. The price is stateful, sticky connections and reconnection logic you now own. The rule: escalate to it on need, never on fashion.&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage and Replication Patterns: Where Truth Lives
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Primary-Replica Replication.&lt;/strong&gt; One machine takes all writes and streams its change log to replicas that serve reads. Read capacity scales by adding copies, and a dead primary is replaced by promoting a replica. The price: replicas lag slightly, so a user can miss their own write, and replicas add zero write capacity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sharding.&lt;/strong&gt; When writes or data size outgrow one machine, split the table's rows across machines by a shard key. The key is the whole game: it should appear in nearly every query, spread load evenly, and keep related rows together. The price: cross-shard queries, cross-shard transactions, and hot keys become your problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consistent Hashing.&lt;/strong&gt; The routing rule that lets a cluster change size gracefully. With naive modulo routing, adding a fifth shard moves 80% of all data. On the hash ring, it moves about 20%: only the slice the new server takes over. Virtual nodes keep the slices even and spread a dead server's load across everyone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write-Ahead Log (WAL).&lt;/strong&gt; Before touching any data structure, the database appends one record describing the change to a log and forces it to disk. Only then does it say "saved." Crash recovery is replaying the log. This one mechanism also powers replication and point-in-time recovery, which makes the append-only log the most important structure in the database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Event Sourcing.&lt;/strong&gt; Store what happened, not what is. Every change is an immutable business event (OrderPlaced, OrderCancelled), and current state is derived by replaying them. Perfect audit trails and time travel, at the cost of projections for queries and event schemas that live forever. The default answer is no; the exception is ledger-shaped domains: money, orders, inventory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CQRS.&lt;/strong&gt; When reads and writes want different shapes, split the model: a lean, validated write model, and read models shaped for each question (a pre-joined table, a search index, an aggregates store), kept in sync from a change stream. Never sync them by writing to both from application code: dual writes drift silently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Caching Patterns: Serving Data Fast
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Cache-Aside.&lt;/strong&gt; The default cache: the application checks the cache, loads from the database on a miss, and stores the result. Two numbers rule everything: the hit ratio and the staleness budget. Invalidation is your job, and the TTL is your safety net.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read-Through.&lt;/strong&gt; The cache itself loads misses from the database, so application code just reads. Cleaner call sites, at the cost of a smarter cache layer in your read path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write-Through.&lt;/strong&gt; Writes go to the cache and the store together, so reads are always warm and never stale. The price: every write pays for both.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write-Behind.&lt;/strong&gt; Writes land in the cache and flush to the store later, in batches. Enormous write throughput, with a window where acknowledged data exists only in memory. Never for money.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cache Stampede Prevention.&lt;/strong&gt; When a popular key expires, a thousand requests can miss at once and crush the database together. The cures: let one request rebuild while others wait (single flight), add jitter to expiry times, and refresh hot keys before they expire.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reliability Patterns: Surviving Failure
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Timeout.&lt;/strong&gt; No wait is allowed to be unbounded. Every network call gets a deadline, chosen from the callee's real latency profile. The subtlety: a timeout means "I stopped waiting," never "it did not happen." The work may have finished after you gave up, which is why idempotency exists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Retry with Exponential Backoff.&lt;/strong&gt; Transient failures deserve a second try, with increasing delays and randomness (jitter) so a thousand clients do not retry in lockstep and finish off a struggling server. Retries without backoff, jitter, and a budget are how outages get worse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Idempotency.&lt;/strong&gt; The same request processed twice must have the effect of once. The client generates a unique key per operation, and the server remembers keys it has seen. This is the pattern that makes retries safe, and the reason a double-clicked "Pay" button charges once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Circuit Breaker.&lt;/strong&gt; When a dependency keeps failing, stop calling it. Fail fast, give it time to recover, and probe occasionally to see if it is back. This turns a slow, cascading failure into a fast, contained one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bulkhead.&lt;/strong&gt; Partition your resources so one workload cannot starve the rest. Separate connection pools, thread pools, or fleets per feature. The symptom it prevents: dashboards green overall while one feature quietly consumed every thread.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dead Letter Queue.&lt;/strong&gt; A message that fails repeatedly gets moved aside into a quarantine queue, so it stops blocking everything behind it. The DLQ needs an owner and an alert, or it becomes a place where problems go to be forgotten.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Graceful Degradation.&lt;/strong&gt; Decide in advance what each feature does when its dependencies fail: serve stale data, show a smaller answer, or refuse. Availability features fail open; money and authorization fail closed. The worst answer is the one nobody designed: a blank error page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scaling Patterns: Growing Under Load
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Vertical Scaling.&lt;/strong&gt; A bigger machine. No new failure modes, no code changes, and it buys you time. It has a ceiling, and at the top of the catalog the prices climb steeply. Exhaust the simple win before taking on distributed problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Horizontal Scaling.&lt;/strong&gt; Many identical, stateless copies behind a load balancer. The catch is the word stateless: sessions, counters, and files must move out of the server first, or each copy holds a different fraction of the truth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Load Balancing.&lt;/strong&gt; Spreading requests across those copies, informed by health checks and actual load. Draining connections before removing a server is the difference between a deploy and an incident.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Auto-Scaling.&lt;/strong&gt; Capacity that follows demand: scheduled scaling for the load you can predict (most of it), reactive scaling for the surprise. Reaction takes minutes, so headroom is part of the design, and the maximum is a safety limit you set on purpose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connection Pooling.&lt;/strong&gt; Opening a database connection is expensive; reuse a small pool of warm ones instead. The quiet trap: pool size multiplies across your fleet, and 50 servers with modest pools can exhaust a database's connection limit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Consistency Patterns: Keeping Data Correct Across Machines
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Two-Phase Commit (2PC).&lt;/strong&gt; The coordinator asks all participants to prepare, then tells them all to commit: atomicity across machines. The price: everyone blocks if the coordinator dies at the wrong moment. It works inside one trust boundary; it does not cross companies. Often the best move is designing the transaction away entirely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Saga.&lt;/strong&gt; A long business transaction as a sequence of local steps, each with a designed compensation (undo) if a later step fails. Book the flight, book the hotel; if the hotel fails, unbook the flight. Order the irreversible steps last. This is how money moves between systems that share no database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quorum.&lt;/strong&gt; Decisions by majority: with three or five copies, require agreement from more than half before an answer counts. Majorities prevent split brain, because two disagreeing majorities cannot exist. The price is latency, and a minority partition that goes read-only on purpose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vector Clocks.&lt;/strong&gt; A way to track causality so the system can tell "this edit came after that one" apart from "these two edits happened concurrently and neither saw the other." Concurrent edits become explicit conflicts to resolve rather than silent overwrites.&lt;/p&gt;

&lt;h3&gt;
  
  
  API and Edge Patterns: The Front Door
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Reverse Proxy.&lt;/strong&gt; One front door for your servers: it terminates TLS, routes requests, and shields the fleet behind it. Nearly every pattern in this category is a specialized reverse proxy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CDN.&lt;/strong&gt; Copies of your content cached at the edge, near users. The two disciplines: getting invalidation right, and never letting private, per-user responses into a shared cache.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API Gateway.&lt;/strong&gt; Cross-cutting policy enforced once: authentication, rate limits, routing to services. The discipline is staying thin. The moment business logic moves in, you have rebuilt the monolith in the doorway.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backend for Frontend (BFF).&lt;/strong&gt; A thin backend per client type (web, mobile) that composes reads into exactly the shape that client needs. Presentation composes reads; the domain services keep owning writes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rate Limiting.&lt;/strong&gt; Protecting capacity by refusing excess politely: token buckets that allow bursts but cap sustained rates, tiered by customer. A 429 with a Retry-After header is a feature, not a failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cursor-Based Pagination.&lt;/strong&gt; Page through data by position ("after item X") instead of offset ("items 51-100"), so results stay stable while new data arrives. The price: no jumping to page seven.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API Versioning.&lt;/strong&gt; Changing an API without breaking its clients: additive changes where possible, versioned contracts where not. Every field you publish is a promise someone will hold you to for years.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sidecar.&lt;/strong&gt; Cross-cutting concerns (TLS, retries, telemetry) packaged as a helper process that runs beside every service instance, in any language. The building block that makes the next pattern possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Service Mesh.&lt;/strong&gt; Sidecars on every service plus a control plane: mutual TLS, retries, timeouts, and telemetry for all service-to-service traffic, without touching application code. A heavy platform. Adopt it when the service count and compliance needs clear the bar, not before.&lt;/p&gt;

&lt;h3&gt;
  
  
  Operations and Delivery Patterns: Shipping Without Breaking
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Health Check Endpoint.&lt;/strong&gt; The difference between "the process is running" (liveness) and "the process can do useful work" (readiness), exposed as endpoints that load balancers and deploys consult. Shallow checks lie; check the dependencies that matter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Distributed Tracing.&lt;/strong&gt; One request's story across every service it touched, stitched together by a trace ID. When the checkout is slow, the trace shows which of the nine hops ate the time. Instrumentation costs effort; debugging without it costs more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blue-Green Deployment.&lt;/strong&gt; Two identical environments; switch traffic instantly, switch back instantly if something breaks. The catch everyone learns once: the database does not blue-green. Schema changes need the expand-contract discipline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Canary Deployment.&lt;/strong&gt; Release to a small slice first, judge it against the current version on real metrics, then widen. The judging is the pattern: a canary without honest verdict metrics is theater.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feature Flags.&lt;/strong&gt; Separate deploying code from releasing behavior. The code ships dark; the behavior turns on with a flag, per cohort, reversible in seconds. The debt: flags must be deleted after they win, or the codebase fills with dead switches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data-Intensive Patterns: Batch and Streaming
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;MapReduce.&lt;/strong&gt; The batch shape: process a huge dataset by working on pieces in parallel where the data lives (map), regrouping by key (shuffle), and merging (reduce). You will never write raw MapReduce, and you will never escape its shape: it is the physics under every warehouse and Spark job.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stream Processing.&lt;/strong&gt; A job that runs forever, holding running counts keyed by the thing being watched, answering while the data is still arriving. Its hard ideas: event time versus arrival time, watermarks that decide when a window may close, and answers that may be amended when stragglers arrive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lambda and Kappa Architectures.&lt;/strong&gt; Two answers to batch and streaming both computing the same numbers. Lambda runs both, with batch overwriting the stream's results on schedule. Kappa keeps one streaming codebase over a replayable log and re-runs history when logic changes. The rule either way: every metric gets exactly one definition of truth. To see these patterns assembled into one design, read &lt;a href="https://www.designgurus.io/blog/data-engineering-system-design" rel="noopener noreferrer"&gt;Data Engineering System Design: Designing a Pipeline End to End&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Change Data Capture (CDC).&lt;/strong&gt; Tail the database's own write-ahead log and publish every committed change as an event. It cannot miss: bulk imports and manual fixes flow through the same log as app writes. This is how search indexes, caches, and warehouses stay in sync without fragile dual writes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exactly-Once Semantics.&lt;/strong&gt; Counting things once despite crashes and retries. Delivery can never be exactly-once; the effect can be, by moving the processing state and the outputs together with the log position. Reserve the heavy machinery for numbers with auditors: billing, ledgers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backpressure.&lt;/strong&gt; When a producer outruns a consumer, something must give: a bounded buffer absorbs bursts, a drop policy sheds what is worthless when stale, or the producer is slowed. The one wrong answer is the unbounded buffer, which schedules an out-of-memory crash instead of surfacing the mismatch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Partitioned Consumption.&lt;/strong&gt; Order per key, parallelism across keys: every event for a given customer lands in the same partition, each partition has exactly one consumer, so a refund can never be processed before its charge. The partition count is a ceiling chosen in advance, and one hot key can still make one partition burn.&lt;/p&gt;

&lt;h3&gt;
  
  
  AI-Era Patterns: LLM and ML Infrastructure
&lt;/h3&gt;

&lt;p&gt;Nothing in the AI stack is architecturally new; every pattern here is one of the above operating under changed constants. But the changed constants matter enough that these seven deserve their own names.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feature Store.&lt;/strong&gt; Define each ML feature once, and let a platform compute it both offline for training and online for serving. This kills training/serving skew: the silent bug where a model learns from one definition of a number and gets served another.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Model Serving and Batching.&lt;/strong&gt; At batch-of-one, a GPU serving an LLM runs at single-digit utilization, because each token step streams the whole model's weights to do almost no math. Continuous batching lets dozens of requests share each weight-pass, multiplying throughput 20-30x. It is the difference between a viable AI feature and an absurd bill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GPU Auto-Scaling.&lt;/strong&gt; Web autoscaling with both dials at 100x: idle GPUs cost a hundred times more, and cold starts take minutes, not seconds. The answers: scale on queue depth (never CPU), keep warm pools as priced insurance, pre-warm on the calendar, and fall back to a smaller model when capacity gaps hit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LLM Gateway.&lt;/strong&gt; One internal door for all model traffic: it holds the provider keys, meters every token against budgets with hard caps, routes logical model names to physical providers, and runs the failover ladder when a provider browns out. The API gateway pattern, pointed outward.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Semantic Caching.&lt;/strong&gt; Forty percent of user questions are rephrasings of known questions, but exact-match caching catches almost none of them. Key the cache by meaning instead: embed the query and match by similarity, with a conservative threshold, because a false hit serves a confidently wrong answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vector Database Sharding.&lt;/strong&gt; Similarity search breaks normal sharding's best rule: a nearest-neighbor query has no shard key, so the default is asking every shard and merging. The escape: when every query is tenant-scoped, the tenant filter becomes the shard key and single-shard routing returns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RAG Pipeline.&lt;/strong&gt; Knowledge in model weights has no update path, no citations, and no access control. Retrieval-Augmented Generation fixes all three: keep documents in an index that updates in seconds, retrieve only what the asker is permitted to read, and require the model to answer from the retrieved text with citations. The model reasons; the index remembers.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. How Patterns Compose: A News Feed in Ten Patterns
&lt;/h2&gt;

&lt;p&gt;A pattern list becomes useful when you see composition. Take the classic prompt: design a social feed. Watch the patterns snap together.&lt;/p&gt;

&lt;p&gt;Reads outnumber writes about 50 to 1, so the feed is a read-serving problem. Precompute each user's feed at write time and serve it like a &lt;strong&gt;cache&lt;/strong&gt;: this is &lt;strong&gt;CQRS&lt;/strong&gt;, with the feed as a read model. Posting fans out through a &lt;strong&gt;message queue&lt;/strong&gt; with &lt;strong&gt;partitioned consumption&lt;/strong&gt;, fed reliably by an &lt;strong&gt;outbox (CDC)&lt;/strong&gt; so a committed post always reaches the pipeline. The feed store is a &lt;strong&gt;sharded&lt;/strong&gt;, &lt;strong&gt;consistent-hashed&lt;/strong&gt; cluster of lists, evicted and rebuilt like any cache. Celebrities with 50 million followers would break write-time fan-out, so their posts merge at read time from a hot cache with &lt;strong&gt;stampede prevention&lt;/strong&gt;. Fan-out workers &lt;strong&gt;auto-scale&lt;/strong&gt; on backlog age. Appends are &lt;strong&gt;idempotent&lt;/strong&gt; so at-least-once delivery cannot duplicate a post. When parts fail, the feed &lt;strong&gt;degrades gracefully&lt;/strong&gt;: slightly stale beats blank.&lt;/p&gt;

&lt;p&gt;Ten-plus patterns, one design, and every choice justified by a number or a failure mode. That is what interviewers mean when they say a candidate "thinks in systems." It is also the skill this entire catalog exists to build: not knowing sixty definitions, but composing the right eight of them under pressure.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. How to Learn These Patterns Properly
&lt;/h2&gt;

&lt;p&gt;Reading a list is recognition. Interviews and production require recall and application. Three suggestions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Learn each pattern through its failure story.&lt;/strong&gt; Every pattern above exists because something broke at 2 AM. "Cache stampede prevention" is forgettable; "a thousand requests missed the same expired key at once and crushed the database" is not. Attach each pattern to its incident.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Always learn the price and the "when not."&lt;/strong&gt; A pattern you cannot argue against is a pattern you do not understand. Sharding from day one, CQRS on a settings page, and event sourcing everywhere are the classic ways to pay real complexity for imaginary scale.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice composition on full designs.&lt;/strong&gt; Run the classic prompts (a feed, a ride-sharing dispatch, a payment platform) and force yourself to name every pattern you use and what it costs, out loud.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is exactly how my course, &lt;strong&gt;&lt;a href="https://www.designgurus.io/course/system-design-patterns?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=sdp-cluster&amp;amp;utm_content=system-design-patterns-complete-guide" rel="noopener noreferrer"&gt;System Design Patterns: From Fundamentals to Real Systems&lt;/a&gt;&lt;/strong&gt;, is built. All sixty-plus patterns above get a full lesson: a real production incident, the naive fixes and why they fail, a walkthrough with real numbers, the trade-offs, when NOT to use it, and a 30-second interview answer you can say under pressure. The course ends with four complete interview walkthroughs (a news feed, ride-sharing dispatch, a payment platform, and an AI copilot) where you watch the sixty patterns compose into real systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Frequently Asked Questions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What are system design patterns?&lt;/strong&gt;&lt;br&gt;
System design patterns are named, reusable solutions to problems that recur in distributed systems: scaling reads, surviving failures, keeping data consistent across machines, and moving data between services. They are architecture-level building blocks, used to design systems like feeds, payment platforms, and chat applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How many system design patterns are there?&lt;/strong&gt;&lt;br&gt;
Around sixty patterns cover essentially everything asked in interviews and used in production, spanning communication, storage, caching, reliability, scaling, consistency, APIs, operations, data engineering, and AI infrastructure. This guide lists all of them by category.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are system design patterns the same as design patterns?&lt;/strong&gt;&lt;br&gt;
No. Classic design patterns (from the Gang of Four book) organize code inside one program: Singleton, Observer, Factory. System design patterns organize infrastructure across many machines: sharding, caching, circuit breakers, sagas. In system design interviews, the interviewer means the architecture-level kind.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which system design patterns matter most for interviews?&lt;/strong&gt;&lt;br&gt;
Eight patterns appear in the overwhelming majority of interview questions: cache-aside, sharding, message queues, circuit breakers, idempotency, sagas, CQRS, and rate limiting. Learn those deeply first, then broaden. The highest-scoring skill is not naming patterns but stating each one's cost as you use it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do AI systems need new system design patterns?&lt;/strong&gt;&lt;br&gt;
Mostly no, and that is good news. The LLM gateway is the API gateway pattern pointed outward, semantic caching is cache-aside with similarity instead of equality, and GPU autoscaling is standard autoscaling with far harsher constants. An engineer who knows the classic sixty walks into AI infrastructure already knowing the building.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Arslan Ahmad is the author of &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt; and founder of DesignGurus.io. His new course, &lt;a href="https://www.designgurus.io/course/system-design-patterns?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=sdp-cluster&amp;amp;utm_content=system-design-patterns-complete-guide" rel="noopener noreferrer"&gt;System Design Patterns: From Fundamentals to Real Systems&lt;/a&gt;, teaches all sixty-plus patterns in this guide through real production incidents.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://www.designgurus.io/blog/system-design-patterns-complete-guide" rel="noopener noreferrer"&gt;DesignGurus.io&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>architecture</category>
      <category>programming</category>
      <category>interview</category>
    </item>
    <item>
      <title>I've taught system design to hundreds of engineers. Here's where I tell them all to start.</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Sat, 04 Jul 2026 03:54:11 +0000</pubDate>
      <link>https://dev.to/arslan_ah/ive-taught-system-design-to-hundreds-of-engineers-heres-where-i-tell-them-all-to-start-3p7g</link>
      <guid>https://dev.to/arslan_ah/ive-taught-system-design-to-hundreds-of-engineers-heres-where-i-tell-them-all-to-start-3p7g</guid>
      <description>&lt;p&gt;Somewhere around the hundredth engineer I coached, I noticed something. Nobody was struggling with system design because it was too hard. They were struggling because they started in the wrong place.&lt;/p&gt;

&lt;p&gt;The pattern was always the same. A smart engineer with two or three years of experience decides it's time to learn system design. They search YouTube, land on "Design Instagram in 45 minutes," and watch someone draw fifteen boxes connected by arrows. They understand maybe four of the boxes. They finish the video feeling like they learned something, try to design anything on their own, and produce a server, a database, and silence.&lt;/p&gt;

&lt;p&gt;Then they conclude system design is a genius-only club, and they either give up or start memorizing diagrams.&lt;/p&gt;

&lt;p&gt;If that's you, nothing is wrong with you. You just entered the building through the roof.&lt;/p&gt;

&lt;p&gt;📚 &lt;strong&gt;Related:&lt;/strong&gt; &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-in-2027-the-best-resources-in-the-order-you-should-use-them-1i94"&gt;How to Learn System Design in 2027: The Best Resources, in the Order You Should Use Them&lt;/a&gt;, a stage-by-stage path with 20 resources and a 10-week plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  The lie that keeps beginners stuck
&lt;/h2&gt;

&lt;p&gt;Here's what I wish someone had told me when I was coming up through Microsoft and Facebook: &lt;strong&gt;system design is not as big as it looks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It looks infinite because content about it has no agreed-upon sequence. Every blog post assumes you already know whatever the last blog post covered. Every video introduces five terms it never defines. There's no "chapter one" anywhere on the front page of Google.&lt;/p&gt;

&lt;p&gt;But strip the noise away and the field that matters for interviews and for real engineering work reduces to roughly 12 recurring patterns, combined in different ways. Netflix is not magic. Uber is not magic. They're the same dozen ideas arranged for different constraints.&lt;/p&gt;

&lt;p&gt;You cannot see that from the roof. You can only see it from the foundation.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 5 concepts I make everyone learn first
&lt;/h2&gt;

&lt;p&gt;When someone asks me where to start, I give them the same assignment every time: learn these five things, and don't touch a case study until you can explain each one to a non-engineer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The client-server model.&lt;/strong&gt; A client asks, a server answers. Every system you will ever design begins with "the client sends a request to our API server." If this sentence isn't boring and obvious to you yet, everything downstream will feel like fog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Databases.&lt;/strong&gt; Where data lives when the power goes out. You need exactly one distinction at this stage: SQL databases are structured and relational, NoSQL databases are flexible and easier to scale horizontally. That's it. Do not fall down the "PostgreSQL vs Cassandra vs DynamoDB" rabbit hole in week one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. APIs.&lt;/strong&gt; The contracts that let pieces of software talk to each other without knowing each other's internals. In a design discussion, APIs are the seams of your architecture: where you cut, and where things can change independently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Load balancing.&lt;/strong&gt; One server can't handle a million users, so you run fifty servers, and something has to decide which request goes where. That something is a load balancer, and it appears in every design answer you will ever give. Think of a restaurant hostess distributing guests across tables so no waiter drowns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Caching.&lt;/strong&gt; Databases are slow compared to memory. If a million people request the same homepage feed, computing it a million times is waste. Store the answer once in RAM, serve it a million times in microseconds. Most of "making systems fast" is some version of this idea.&lt;/p&gt;

&lt;p&gt;That's the whole first week. Five concepts. Engineers are usually suspicious of how small this list is, and then a month later they tell me it's the reason the rest finally made sense.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this order beats the "just watch case studies" approach
&lt;/h2&gt;

&lt;p&gt;Case studies are the best part of learning system design. They're also nearly worthless if you do them first.&lt;/p&gt;

&lt;p&gt;When you watch "Design a URL Shortener" without knowing the building blocks, you're memorizing a specific answer. When the constraints change ("what if reads are 100x writes?"), the memorized answer shatters, because you never knew &lt;em&gt;why&lt;/em&gt; the cache was there in the first place.&lt;/p&gt;

&lt;p&gt;When you do the same case study &lt;em&gt;after&lt;/em&gt; learning the blocks, you're doing something completely different: you're practicing selection. You know what a cache does, so the question becomes "does this system need one, and where?" That's the actual skill interviewers grade. It's also the actual skill your job requires.&lt;/p&gt;

&lt;p&gt;Same video. Same diagram. Entirely different learning outcome, purely based on what you knew walking in.&lt;/p&gt;

&lt;h2&gt;
  
  
  The sequence that works
&lt;/h2&gt;

&lt;p&gt;After the first five concepts, the path I give people looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Learn the next 7 building blocks&lt;/strong&gt;: sharding, replication, consistency models, message queues, CDNs, indexing, and back-of-the-envelope estimation. Same rule as before: understand what problem each one solves, skip the depth.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learn a framework.&lt;/strong&gt; Requirements, estimation, API, data model, high-level architecture, deep dives, trade-offs. In that order, every time. A framework turns "design Twitter" from a blank-whiteboard panic into a sequence of small, answerable questions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Now do case studies.&lt;/strong&gt; Start with the URL shortener, then a chat app, then a news feed. Attempt each one yourself, out loud, for 45 minutes before you look at any solution. The gap between your answer and the reference answer is your personalized curriculum.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice out loud, with a human if possible.&lt;/strong&gt; System design interviews are conversations, not exams. I've seen engineers who knew plenty fail because the first time they'd ever articulated a trade-off verbally was in the actual interview.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Spread over eight weeks at an hour or two a day, this takes someone from "what's a load balancer?" to holding a coherent 45-minute design conversation. I've written the full week-by-week version, with links for every concept, in my &lt;a href="https://www.designgurus.io/blog/system-design-for-beginners" rel="noopener noreferrer"&gt;system design roadmap for beginners&lt;/a&gt; if you want the detailed plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three failure modes to watch for
&lt;/h2&gt;

&lt;p&gt;After enough repetitions, I can predict how someone will get stuck before they start:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The memorizer&lt;/strong&gt; collects architecture diagrams like trading cards and freezes the moment an interviewer changes one constraint. Fix: for every component in a design, force yourself to answer "what breaks if I remove this?"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The roof-jumper&lt;/strong&gt; goes straight to "Design WhatsApp" content and drowns in jargon. Fix: the five concepts above, first, no exceptions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The passive consumer&lt;/strong&gt; watches 30 hours of videos, feels fluent, and can't produce a design from a blank page. Fix: never end a study session without explaining what you learned out loud, to a rubber duck if necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three failure modes share a root cause: consuming content feels like progress, and applying concepts feels like struggle. The struggle is the part that works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start smaller than feels reasonable
&lt;/h2&gt;

&lt;p&gt;If you take one thing from this post, make it this: the engineers who get good at system design are not the ones who were smarter. They're the ones who started with embarrassingly basic material and actually practiced it, while everyone else skipped ahead and silently churned.&lt;/p&gt;

&lt;p&gt;Client-server. Databases. APIs. Load balancing. Caching. Learn those five this week, explain each one out loud to someone patient, and you'll be ahead of most people grinding case study videos.&lt;/p&gt;

&lt;p&gt;And when you're ready for the structured version of the whole journey, the &lt;a href="https://www.designgurus.io/blog/system-design-for-beginners" rel="noopener noreferrer"&gt;full 8-week roadmap&lt;/a&gt; is free, and my &lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals" rel="noopener noreferrer"&gt;System Design Fundamentals&lt;/a&gt; course covers the building-blocks phase in one sequenced curriculum if you'd rather not assemble it yourself.&lt;/p&gt;

&lt;p&gt;You don't need to be a distributed-systems wizard to start. You need chapter one. Now you have it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What tripped you up when you started learning system design? I read every comment.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>beginners</category>
      <category>architecture</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>System Design Fundamentals: The 10 Building Blocks to Learn First</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Thu, 02 Jul 2026 12:57:22 +0000</pubDate>
      <link>https://dev.to/arslan_ah/system-design-fundamentals-the-10-building-blocks-to-learn-first-2754</link>
      <guid>https://dev.to/arslan_ah/system-design-fundamentals-the-10-building-blocks-to-learn-first-2754</guid>
      <description>&lt;p&gt;Most people learn system design backwards. They start by reading how Netflix or Uber is built, memorize the finished architecture, and then freeze the moment they're asked to design something slightly different.&lt;/p&gt;

&lt;p&gt;The fix is to learn the &lt;em&gt;parts&lt;/em&gt; before the &lt;em&gt;whole&lt;/em&gt;. Every large system is assembled from a small set of reusable building blocks. Once you understand each block on its own, designing a full system becomes an exercise in choosing which blocks to combine and why. This post covers the 10 to learn first, in a sensible order, so you have the vocabulary before you attempt your first design. If you want to see where these fit in the bigger picture, here's a structured roadmap to &lt;a href="https://www.designgurus.io/learn-system-design" rel="noopener noreferrer"&gt;learn system design&lt;/a&gt; at your level.&lt;/p&gt;

&lt;p&gt;📚 &lt;strong&gt;Related:&lt;/strong&gt; &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-in-2027-the-best-resources-in-the-order-you-should-use-them-1i94"&gt;How to Learn System Design in 2027: The Best Resources, in the Order You Should Use Them&lt;/a&gt;, a stage-by-stage path with 20 resources and a 10-week plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to study each block: solves, costs, when
&lt;/h2&gt;

&lt;p&gt;Do not just memorize what each component &lt;em&gt;is&lt;/em&gt;. For every block, learn three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What it solves.&lt;/strong&gt; The specific problem that makes you reach for it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What it costs.&lt;/strong&gt; The new problem it introduces (every block adds one).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When to use it.&lt;/strong&gt; The signal in a design that says "now I need this."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That third habit is what separates people who can design real systems from people who can only recite them. Keep those three columns in mind as you read.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Load Balancer
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A traffic cop that sits in front of multiple servers and spreads incoming requests across them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; A single server can only handle so much. A load balancer lets you run many identical servers and distribute load, which gives you both scale and redundancy (if one server dies, traffic routes to the others).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; It becomes a component you have to make highly available itself, and it forces your servers to be stateless (or you have to deal with sticky sessions).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; The moment you say "one server isn't enough" or "what happens if this server goes down."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuarnmfttxhmx0aib1hq1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuarnmfttxhmx0aib1hq1.png" alt="Load Balancer" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Caching
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A fast, temporary store for data you access often, sitting between your app and a slower source (like a database).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Latency and load. Reading from memory is orders of magnitude faster than hitting a database, and it takes pressure off your data store.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Staleness. The cached copy can drift from the source of truth, so now you own cache invalidation, famously one of the hard problems in computing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; Read-heavy workloads, or any time the same data is requested over and over.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiypoupn9xzwnf2k8vb7z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiypoupn9xzwnf2k8vb7z.png" alt="Caching" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Database Replication
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; Keeping copies of your database on multiple machines, usually one primary (writes) and several replicas (reads).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Read scalability and availability. You can spread reads across replicas, and if the primary fails, a replica can take over.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Replication lag. Replicas can be slightly behind the primary, so a user might not immediately see their own write. That's the consistency trade-off.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; When reads vastly outnumber writes, or when you can't afford to lose the database if one machine fails.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Database Sharding
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; Splitting one large database into smaller pieces (shards), each holding a subset of the data, spread across machines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Write scalability and storage limits. When the data or write volume outgrows a single machine, sharding partitions the load.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; A large jump in complexity. Cross-shard queries get hard, and choosing a bad shard key creates "hot" shards that defeat the whole purpose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; When a single database server can no longer hold your data or absorb your writes, and only then. Replication first, sharding later.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Message Queue
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A buffer that holds messages so one part of your system can hand off work to another without waiting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Decoupling and load smoothing. Producers and consumers work at their own pace, and traffic spikes get absorbed by the queue instead of crushing a service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Added latency (work is now asynchronous) and new failure modes (duplicate messages, ordering, what happens when the queue backs up).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; When work can happen later rather than instantly (sending emails, processing uploads, generating notifications). When you are ready to pick a tool, &lt;a href="https://www.designgurus.io/blog/kafka-vs-rabbitmq" rel="noopener noreferrer"&gt;Kafka vs RabbitMQ: Log vs Queue, and How to Choose&lt;/a&gt; compares the two most common options, and &lt;a href="https://www.designgurus.io/blog/event-driven-architecture" rel="noopener noreferrer"&gt;Event-Driven Architecture: Patterns, Diagrams, and When to Use It Over Request-Response&lt;/a&gt; shows where queues fit in a larger design.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Consistent Hashing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A clever way to distribute data across a changing set of servers so that adding or removing a server only moves a small fraction of the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; The rehashing problem. With naive hashing, adding one server reshuffles almost everything. Consistent hashing keeps that disruption minimal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Conceptual complexity, and the need for tricks like virtual nodes to keep the distribution even.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; Any time you're distributing data or requests across a cluster whose size changes (caches, sharded stores). I broke this one down step by step in &lt;a href="https://dev.to/arslan_ah/how-to-use-consistent-hashing-in-a-system-design-interview-33ge"&gt;consistent hashing in a system design interview&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. CDN (Content Delivery Network)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A globally distributed network of servers that cache your static content close to users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Latency for a global audience. Serving an image or video from a city near the user is far faster than from one origin server across the world.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Cost, plus cache invalidation again (pushing updates to edge locations takes time).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; When you serve static assets (images, video, JS/CSS) to users spread across regions.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Rate Limiter
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A guard that caps how many requests a client can make in a given window.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Abuse and overload. It protects your system from being overwhelmed, whether by malicious traffic, buggy clients, or a single user hammering an endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; You have to store and check counters fast (often in a cache), and you have to decide what to do with rejected requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; Any public API, login endpoint, or any resource you need to protect from spikes and abuse.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Database Indexing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A data structure that lets the database find rows without scanning the entire table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Slow reads. An index turns a full-table scan into a fast lookup, dramatically speeding up queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Slower writes (every write must update the index) and extra storage. Over-indexing is a real mistake.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; When a query is slow and it filters or sorts on a specific column. This is often the cheapest performance win available.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Data Modeling
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; Deciding how your data is structured and stored: relational tables versus documents, how entities relate, what you optimize for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Almost everything downstream. The right model makes your common queries easy and fast; the wrong one makes every later decision harder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Time and foresight up front, and the reality that changing the model later is painful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; First. Before you pick components, understand your data and its access patterns. This is the foundation the other nine blocks sit on.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the blocks combine
&lt;/h2&gt;

&lt;p&gt;Here's the payoff. Take a simple service and watch the blocks appear as constraints arrive:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start with one server and a database (data modeling).&lt;/li&gt;
&lt;li&gt;Traffic grows, so you add more servers behind a &lt;strong&gt;load balancer&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Reads are slow, so you add a &lt;strong&gt;cache&lt;/strong&gt; and some &lt;strong&gt;indexes&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Reads still outpace one database, so you add &lt;strong&gt;replication&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The data outgrows one machine, so you &lt;strong&gt;shard&lt;/strong&gt; it (using &lt;strong&gt;consistent hashing&lt;/strong&gt;).&lt;/li&gt;
&lt;li&gt;Some work doesn't need to be instant, so you offload it to a &lt;strong&gt;message queue&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Users are global, so static assets move to a &lt;strong&gt;CDN&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The public API needs protection, so you add a &lt;strong&gt;rate limiter&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every block entered the design because a specific problem demanded it, not because a checklist said so. That's exactly how you should reason in a real design.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to learn next
&lt;/h2&gt;

&lt;p&gt;Learn these 10 in roughly the order above (data modeling first, sharding and consistent hashing last, since they're the most advanced). Write your own three-line summary for each: solves, costs, when. Then start composing them into full systems.&lt;/p&gt;

&lt;p&gt;If you're brand new and even the prerequisites feel shaky, start with &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-from-scratch-with-no-distributed-systems-experience-1591"&gt;learning system design from scratch&lt;/a&gt;. And when you're ready to see how deep each block should go at your career stage, follow the full path in this &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-a-roadmap-by-career-level-3e01"&gt;roadmap by career level&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Master the parts, and the whole stops being intimidating. Every "complex" architecture you've ever admired is just these blocks, combined to answer specific constraints.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>programming</category>
      <category>computerscience</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>How to Learn System Design From Scratch (With No Distributed Systems Experience)</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Tue, 30 Jun 2026 21:24:53 +0000</pubDate>
      <link>https://dev.to/arslan_ah/how-to-learn-system-design-from-scratch-with-no-distributed-systems-experience-1591</link>
      <guid>https://dev.to/arslan_ah/how-to-learn-system-design-from-scratch-with-no-distributed-systems-experience-1591</guid>
      <description>&lt;p&gt;If you have ever opened a system design article, seen a diagram with twelve boxes, three databases, a message queue, and the words "eventually consistent," and quietly closed the tab, this post is for you.&lt;/p&gt;

&lt;p&gt;There is a myth that you need years of experience running large systems before you can learn system design. You don't. Plenty of engineers learn it before they have ever deployed anything bigger than a side project. What you actually need is the right starting point and a way to build intuition without access to production-scale traffic. That is exactly what this guide gives you.&lt;/p&gt;

&lt;p&gt;📚 &lt;strong&gt;Related:&lt;/strong&gt; &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-in-2027-the-best-resources-in-the-order-you-should-use-them-1i94"&gt;How to Learn System Design in 2027: The Best Resources, in the Order You Should Use Them&lt;/a&gt;, a stage-by-stage path with 20 resources and a 10-week plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  "But I've never built anything at scale"
&lt;/h2&gt;

&lt;p&gt;Good news: neither had most people the first time they learned this. System design is not a memory test about how Uber works. It is a &lt;em&gt;thinking&lt;/em&gt; skill: given a vague problem and some constraints, make a sequence of reasonable trade-offs and explain them clearly.&lt;/p&gt;

&lt;p&gt;That skill does not require having operated a system serving millions of users. It requires understanding what the moving parts do and practicing the reasoning. The experience helps later, but it is not the price of entry. So drop the idea that you are "not ready." You are ready to start today.&lt;/p&gt;

&lt;h2&gt;
  
  
  The honest minimum prerequisites
&lt;/h2&gt;

&lt;p&gt;You do not need much, but you do need these four things. If any feels shaky, spend a few days here first; it will save you weeks of confusion later.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;What happens when you load a web page.&lt;/strong&gt; Client sends a request, DNS resolves a name to an address, a server responds. If you can sketch that, you're fine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The two kinds of databases.&lt;/strong&gt; Relational (tables, rows, SQL) versus non-relational (documents, key-value). You don't need to be an expert, just know they exist and roughly when each fits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What an index is.&lt;/strong&gt; A way to find data fast without scanning everything. That one sentence is enough to begin.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Basic estimation.&lt;/strong&gt; If something gets a million requests a day, roughly how many is that per second? (About 12, for the record.) The ability to do rough math out loud matters more than precision.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Notice what is &lt;em&gt;not&lt;/em&gt; on this list: Kubernetes, Kafka, distributed consensus, the CAP theorem. Beginners reach for those far too early. You will learn them when a problem actually demands them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The mindset shift that unlocks everything
&lt;/h2&gt;

&lt;p&gt;Beginners try to learn system design by collecting answers: how is Instagram's feed built, how does WhatsApp deliver messages, how does YouTube store video. They memorize a dozen "reference architectures" and feel productive.&lt;/p&gt;

&lt;p&gt;Then they get asked to design something slightly different, and nothing transfers.&lt;/p&gt;

&lt;p&gt;The fix is to learn &lt;em&gt;reasoning&lt;/em&gt;, not answers. For every component you study, learn two things: &lt;strong&gt;what problem it solves&lt;/strong&gt; and &lt;strong&gt;what new problem it creates.&lt;/strong&gt; A cache makes reads fast (solves latency) but can serve stale data (creates a consistency problem). A queue smooths traffic spikes (solves load) but adds delay and complexity (creates new failure modes). Once you think in those trade-offs, you can design things you have never seen before. That is the whole game.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your first design: build it, don't read it
&lt;/h2&gt;

&lt;p&gt;Reading designs builds recognition. Building one builds competence. So for your very first system, pick something small enough to finish in one sitting and deep enough to teach the core ideas. The classic choice is a URL shortener (think bit.ly), and it is the perfect no-experience starter.&lt;/p&gt;

&lt;p&gt;Here is the trick that makes it work: &lt;strong&gt;start with the dumbest possible version, then break it on purpose.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Version 1, the naive design.&lt;/strong&gt; One server, one database. A user submits a long URL, you generate a short code, store the pair, and redirect on lookup. That's it. It works for ten users. Congratulations, you have designed a system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Now add a constraint.&lt;/strong&gt; "It needs to handle 100 million redirects a day." Suddenly your single database read on every redirect is a problem. What solves slow reads? A cache. So you add one. (And now you own the staleness trade-off you just learned about.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add another.&lt;/strong&gt; "Short codes must never collide." Now you have to think about how codes are generated: random with a uniqueness check, or a counter, or a hash. Each has trade-offs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add one more.&lt;/strong&gt; "One database server can't hold all the data." Now you need to split it across machines, which is your gentle introduction to sharding.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See what happened? Each constraint forced &lt;em&gt;exactly one&lt;/em&gt; new idea, and you learned that idea because you needed it, not because a textbook listed it. That is how real systems grow, and it is how you should learn. For a full worked version of this exact problem, see my walkthrough of &lt;a href="https://dev.to/arslan_ah/system-design-interview-question-designing-a-url-shortening-service-4029"&gt;designing a URL shortening service&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to build intuition without a production system
&lt;/h2&gt;

&lt;p&gt;You can't experiment on real traffic yet, so build intuition these three ways instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Read with a question, not a highlighter.&lt;/strong&gt; When you read how a real system works, stop at each component and ask "what would break if they removed this?" If you can answer, you understand it. If you can't, that's the part to study next.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build small versions for real.&lt;/strong&gt; A rate limiter is a weekend project. A simple key-value cache is a weekend project. A basic message queue is a weekend project. Building a tiny version teaches you more than reading about the big version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reason about apps you already use.&lt;/strong&gt; Every time you use an app, ask one design question. Why does the like count sometimes look slightly off? (Probably caching.) Why can you send a message offline and it sends later? (Probably a queue.) You are surrounded by free case studies.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A 4-week beginner ramp
&lt;/h2&gt;

&lt;p&gt;If you want a path instead of a pile of topics, here is a realistic one. Forty focused minutes a day beats a frantic weekend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 1: Foundations.&lt;/strong&gt; One building block per day: load balancer, cache, database replication, sharding, message queue. For each, write three sentences (what it solves, what it costs, when to use it).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 2: Your first systems.&lt;/strong&gt; Design the URL shortener end to end, evolving it under constraints as shown above. Then do a second small one (a pastebin or a basic image host) the same way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 3: A bigger system.&lt;/strong&gt; Attempt a news feed or a chat app. You will get stuck. That is the point; the stuck moments tell you exactly what to study next.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 4: Practice out loud.&lt;/strong&gt; Re-design two earlier systems from a blank page, talking through every decision as if explaining to someone. If you can't explain a choice, you haven't learned it yet.&lt;/p&gt;

&lt;p&gt;After four weeks you won't be a senior architect, but you will no longer be a beginner, and you will know how to keep going.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beginner mistakes to skip
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Starting with the "impressive" architecture.&lt;/strong&gt; Microservices and Kafka on day one is a red flag, not a flex. Start simple, justify every addition.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memorizing reference designs.&lt;/strong&gt; You will be asked something off-script. Learn the reasoning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Studying components you never use.&lt;/strong&gt; You don't need to deeply understand distributed consensus to design a URL shortener. Learn things when a problem demands them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practicing silently.&lt;/strong&gt; System design is a communication skill. If you only think it through in your head, you are training the wrong muscle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skipping the math.&lt;/strong&gt; "It scales" is not an answer. Rough numbers are what justify your choices.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Do I really not need experience with big systems?&lt;/strong&gt;&lt;br&gt;
Correct. Experience accelerates intuition later, but the building-block-then-composition path works fine without it. Many engineers learn system design before ever operating one at scale.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long until I'm "good"?&lt;/strong&gt;&lt;br&gt;
For a solid beginner foundation, about 4 weeks of consistent practice. Genuine mastery is a multi-year, on-the-job journey, and that's normal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is this only useful for interviews?&lt;/strong&gt;&lt;br&gt;
No. The same skill (making and defending trade-offs) is exactly what you do when designing real systems at work. Interview prep is just a concentrated version of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to go next
&lt;/h2&gt;

&lt;p&gt;Once the fundamentals click, the natural next step is to study what depth is expected at each stage of your career. When you're ready, here's &lt;a href="https://www.designgurus.io/learn-system-design" rel="noopener noreferrer"&gt;where to start learning system design&lt;/a&gt; with a level-by-level path, and a companion roadmap that lays out the same journey &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-a-roadmap-by-career-level-3e01"&gt;as a roadmap by career level&lt;/a&gt;. And when the interview itself is on the calendar, &lt;a href="https://arslan-ahmad.medium.com/the-complete-system-design-interview-guide-for-2027-85a1ab94ace7" rel="noopener noreferrer"&gt;The Complete System Design Interview Guide for 2027&lt;/a&gt; covers the framework, the scoring signals, and a full worked example.&lt;/p&gt;

&lt;p&gt;The engineers who get good at this are not the ones who read the most. They are the ones who designed the most systems out loud, starting with the dumbest possible version and letting the constraints teach them. You can start that today, with zero experience. Pick the URL shortener, build the naive version, then break it.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>beginners</category>
      <category>career</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Learn System Design: A Roadmap by Career Level</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Mon, 29 Jun 2026 10:53:47 +0000</pubDate>
      <link>https://dev.to/arslan_ah/how-to-learn-system-design-a-roadmap-by-career-level-3e01</link>
      <guid>https://dev.to/arslan_ah/how-to-learn-system-design-a-roadmap-by-career-level-3e01</guid>
      <description>&lt;p&gt;Most engineers do not struggle with system design because they lack intelligence. They struggle because the topic has no obvious starting point and no obvious finish line. Coding has LeetCode. System design has... a thousand blog posts, a few thick books, and a lot of hand-waving about "scalability."&lt;/p&gt;

&lt;p&gt;This guide fixes the starting-point problem. It lays out how to learn system design as a sequence: what to learn first, what to learn next, and what "good enough" looks like at each stage of your career. If you want the fuller, continuously updated version, Design Gurus maintains a structured guide on &lt;a href="https://www.designgurus.io/learn-system-design" rel="noopener noreferrer"&gt;how to learn system design&lt;/a&gt; organized by career level. This article gives you the condensed roadmap.&lt;/p&gt;

&lt;p&gt;📚 &lt;strong&gt;Related:&lt;/strong&gt; &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-in-2027-the-best-resources-in-the-order-you-should-use-them-1i94"&gt;How to Learn System Design in 2027: The Best Resources, in the Order You Should Use Them&lt;/a&gt;, a stage-by-stage path with 20 resources and a 10-week plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learning system design is not memorizing architectures
&lt;/h2&gt;

&lt;p&gt;The most common mistake is treating system design like trivia: memorize how Twitter's feed works, how Uber matches drivers, how a URL shortener generates keys. You can recite all of it and still freeze when asked to design something you have not seen.&lt;/p&gt;

&lt;p&gt;System design is a &lt;em&gt;skill&lt;/em&gt;, not a &lt;em&gt;fact set&lt;/em&gt;. The skill is this: given a vague problem and real constraints, make a sequence of defensible trade-offs and communicate them clearly. Everything below is built to train that skill, not to pad your memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites: what you need before you start
&lt;/h2&gt;

&lt;p&gt;You do not need to be a senior engineer to begin, but you do need a few fundamentals. If any of these are shaky, shore them up first:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Networking basics:&lt;/strong&gt; what happens when a client calls a server (DNS, TCP, HTTP, status codes).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Databases:&lt;/strong&gt; the difference between a relational and a non-relational store, what an index is, what a transaction is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Concurrency basics:&lt;/strong&gt; what a race condition is, why shared state is hard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Back-of-the-envelope math:&lt;/strong&gt; powers of two, latency numbers, how to estimate QPS and storage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you can comfortably explain those at a whiteboard, you are ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three-phase learning path
&lt;/h2&gt;

&lt;p&gt;Every effective learning sequence I have seen follows the same arc. Skipping a phase is the fastest way to plateau.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 1: Foundations (learn the building blocks in isolation)
&lt;/h3&gt;

&lt;p&gt;Before you compose a system, you need to understand its parts well enough to know when each one applies. Learn these one at a time, and for each, learn &lt;em&gt;what problem it solves&lt;/em&gt; and &lt;em&gt;what it costs&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load balancers&lt;/li&gt;
&lt;li&gt;Caching (and cache invalidation strategies)&lt;/li&gt;
&lt;li&gt;Database replication and sharding&lt;/li&gt;
&lt;li&gt;Message queues and asynchronous processing&lt;/li&gt;
&lt;li&gt;Consistent hashing&lt;/li&gt;
&lt;li&gt;CDNs&lt;/li&gt;
&lt;li&gt;Rate limiting&lt;/li&gt;
&lt;li&gt;Indexing and data modeling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do not move on until you can answer, for each: "When would I add this, and what new problem does adding it create?" Caching, for example, solves latency but creates staleness. That trade-off framing is the entire game.&lt;/p&gt;

&lt;p&gt;For a deeper breakdown of each block (what it solves, what it costs, and when to reach for it), see &lt;a href="https://dev.to/arslan_ah/system-design-fundamentals-the-10-building-blocks-to-learn-first-2754"&gt;the 10 system design building blocks to learn first&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 2: Composition (assemble blocks into systems)
&lt;/h3&gt;

&lt;p&gt;Now combine the blocks. Take a classic prompt and build it up incrementally. A good first target is a URL shortener: simple enough to finish, deep enough to touch key generation, storage, caching, and read/write skew.&lt;/p&gt;

&lt;p&gt;The key habit here is to &lt;strong&gt;start simple and evolve under pressure&lt;/strong&gt;. Begin with the naive single-server design, then introduce a constraint ("now it serves 100M requests a day") and react to it. Each constraint should force exactly one architectural change. That is how real systems grow, and it is how interviewers expect you to think.&lt;/p&gt;

&lt;p&gt;Work through 8 to 12 canonical systems this way: a news feed, a chat app, a rate limiter, a typeahead service, a video platform, a ride-sharing matcher, a notification system. The repetition builds pattern recognition.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 3: Practice (perform under realistic conditions)
&lt;/h3&gt;

&lt;p&gt;Reading designs builds recognition. Producing them under a clock builds competence. In this phase you design out loud, on a timer, ideally with someone pushing back. The full &lt;a href="https://www.designgurus.io/learn-system-design" rel="noopener noreferrer"&gt;system design learning roadmap by level&lt;/a&gt; breaks down how much practice each career stage actually needs, but the principle is constant: you only own a concept once you can explain it without notes.&lt;/p&gt;

&lt;p&gt;The most realistic version of this is a full mock interview. This &lt;a href="https://www.designgurus.io/blog/system-design-mock-interview" rel="noopener noreferrer"&gt;guide to system design mock interviews&lt;/a&gt; explains how a 45-minute mock is structured and scored, and compares solo, peer, expert, and AI practice options.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to learn at each career level
&lt;/h2&gt;

&lt;p&gt;"Learn system design" means different things depending on where you are. Calibrate your depth to your target level so you neither under-prepare nor waste months on staff-level concerns you will not be asked about.&lt;/p&gt;

&lt;h3&gt;
  
  
  Junior (L3)
&lt;/h3&gt;

&lt;p&gt;The bar is fundamentals, not novel architecture. You should be able to design a basic CRUD service, expose a clean API, pick a reasonable database, and explain a single caching layer. Depth of building blocks matters more than breadth of systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mid-level (L4)
&lt;/h3&gt;

&lt;p&gt;Now you compose. You should design a complete system end to end, identify bottlenecks, and reason about scaling reads vs writes. You are expected to know when to shard, when to add a queue, and what consistency model fits the use case.&lt;/p&gt;

&lt;h3&gt;
  
  
  Senior (L5)
&lt;/h3&gt;

&lt;p&gt;The focus shifts to trade-offs and justification. Two valid designs exist for almost every problem; your job is to pick one and defend it against the alternative. Expect deep dives: "Walk me through exactly how you keep the cache consistent here." Non-functional requirements (availability, latency targets, cost) drive your decisions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Staff and above (L6+)
&lt;/h3&gt;

&lt;p&gt;The scope widens beyond one system to platforms and organizations. You reason about evolvability, migration paths, failure domains, multi-region strategy, and the human cost of operating what you propose. The question is less "does it work" and more "will this still be the right call in three years." See &lt;a href="https://www.designgurus.io/blog/staff-engineer-vs-senior-engineer" rel="noopener noreferrer"&gt;Staff Engineer vs Senior Engineer: Scope, Expectations, Interview Bar&lt;/a&gt; for how the scope and interview bar change, and &lt;a href="https://www.designgurus.io/blog/staff-engineer-levels" rel="noopener noreferrer"&gt;Staff Engineer Levels at Google, Meta, Amazon and Apple (L6, E6, ICT5)&lt;/a&gt; for how the level maps across companies.&lt;/p&gt;

&lt;h2&gt;
  
  
  A concrete weekly cadence
&lt;/h2&gt;

&lt;p&gt;If you want a plan rather than a pile of topics, here is a sustainable rhythm:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Weeks 1 to 2:&lt;/strong&gt; One building block per day from Phase 1. Write a three-sentence summary of each (problem it solves, cost it adds, when to reach for it).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weeks 3 to 5:&lt;/strong&gt; One full system every two days from Phase 2, evolving each from naive to scaled.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weeks 6 onward:&lt;/strong&gt; Timed mock designs from Phase 3, two per week, reviewed honestly afterward.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Consistency beats intensity. Forty focused minutes a day will outperform a frantic weekend cram every time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes that stall people
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Jumping to the "impressive" architecture immediately.&lt;/strong&gt; Start with the simplest thing that works, then justify each addition. Leading with Kafka and microservices for a problem that needs neither is a red flag.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memorizing reference designs.&lt;/strong&gt; You will be asked something off-script. Learn the reasoning, not the diagram.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ignoring requirements.&lt;/strong&gt; Spending zero time clarifying scope and then designing the wrong system is the most common failure mode, and the most avoidable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practicing silently.&lt;/strong&gt; System design is a communication exercise. If you only practice in your head, you are training the wrong muscle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skipping the math.&lt;/strong&gt; "It scales" is not an answer. Numbers (QPS, storage, bandwidth) are what justify your choices.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How long does it take to learn system design?&lt;/strong&gt;&lt;br&gt;
For interview readiness, most engineers need 4 to 8 weeks of consistent practice on top of solid fundamentals. Genuine mastery is a multi-year, on-the-job process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do I need real distributed-systems experience first?&lt;/strong&gt;&lt;br&gt;
No. Experience helps, but the building-block-then-composition path works without it. Plenty of engineers learn this before they have ever operated a large system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is system design only for interviews?&lt;/strong&gt;&lt;br&gt;
No. The same skill (making and defending architectural trade-offs) is exactly what you do when designing real systems at work. Interview prep is just a focused version of it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do I need real distributed-systems experience first?&lt;/strong&gt;&lt;br&gt;
No. Experience helps, but the building-block-then-composition path works without it. Plenty of engineers learn this before they have ever operated a large system. If you're starting from zero, I wrote a companion guide on &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-from-scratch-with-no-distributed-systems-experience-1591"&gt;learning system design from scratch with no experience&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to go next
&lt;/h2&gt;

&lt;p&gt;Pick your level, start at Phase 1, and do not skip ahead. If you want the structured, regularly updated version of this path with level-specific checklists, work through Design Gurus' guide on &lt;a href="https://www.designgurus.io/learn-system-design" rel="noopener noreferrer"&gt;how to learn system design&lt;/a&gt;. And when you are ready to drill full problems with worked solutions, &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt; walks through the canonical systems end to end.&lt;/p&gt;

&lt;p&gt;The engineers who get good at this are not the ones who read the most. They are the ones who designed the most systems out loud. Start today, start simple, and let the constraints teach you.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>programming</category>
      <category>interview</category>
      <category>career</category>
    </item>
    <item>
      <title>Must-do system design questions.</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Thu, 25 Jun 2026 11:39:21 +0000</pubDate>
      <link>https://dev.to/arslan_ah/must-do-system-design-questions-4n46</link>
      <guid>https://dev.to/arslan_ah/must-do-system-design-questions-4n46</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" class="crayons-story__hidden-navigation-link"&gt;64 System Design Interview Questions, Ranked From Easiest to Hardest&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/arslan_ah" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F34147%2F2974e0a5-f688-45b5-a4c9-5fa49c257854.jpg" alt="arslan_ah profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/arslan_ah" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Arslan Ahmad
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Arslan Ahmad
                
                
              
              &lt;div id="story-author-preview-content-3488973" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/arslan_ah" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F34147%2F2974e0a5-f688-45b5-a4c9-5fa49c257854.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Arslan Ahmad&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Apr 12&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" id="article-link-3488973"&gt;
          64 System Design Interview Questions, Ranked From Easiest to Hardest
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/systemdesign"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;systemdesign&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/softwaredevelopment"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;softwaredevelopment&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/interview"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;interview&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;17&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            19 min read
          &lt;/small&gt;
          
          &lt;div class="only-sidebar-menu-item trusted-visible-block print-hidden align-center"&gt;
                
                    
                
          &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;/div&gt;


</description>
      <category>architecture</category>
      <category>career</category>
      <category>interview</category>
      <category>systemdesign</category>
    </item>
  </channel>
</rss>
