<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ System Architecture - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ System Architecture - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Tue, 28 Jul 2026 17:16:46 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/system-architecture/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ Learn Key System Design Principles Behind High-Traffic Platforms Like Gaming and Job Discovery ]]>
                </title>
                <description>
                    <![CDATA[ Over the last three months, life has had me juggling a lot – managing my marriage, taking care of family health issues, and overseeing new construction work at home. Somehow, I got through it all. But looking back, I realised something important: I c... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/learn-key-system-design-principles-behind-high-traffic-platforms-like-gaming-and-job-discovery/</link>
                <guid isPermaLink="false">68a5f915c3b51ce78e8f92b3</guid>
                
                    <category>
                        <![CDATA[ System Design ]]>
                    </category>
                
                    <category>
                        <![CDATA[ System Architecture ]]>
                    </category>
                
                    <category>
                        <![CDATA[ full stack ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Prankur Pandey ]]>
                </dc:creator>
                <pubDate>Wed, 20 Aug 2025 16:34:29 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755707525928/f4a02c14-fe62-4d6f-9afc-d887d45a98d4.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Over the last three months, life has had me juggling a lot – managing my marriage, taking care of family health issues, and overseeing new construction work at home. Somehow, I got through it all. But looking back, I realised something important: I could’ve handled it much better if I had a <em>system</em> in place.</p>
<p>For me, a <strong>system</strong> means a set of rules, processes, and triggers that guide the entire workflow. This helps you conserve energy and not have to figure things out in the moment. It keeps things productive, efficient, and consistent.</p>
<p>Now that the chaos has settled, I’ve been thinking a lot about systems – not just in life, but in tech. I wish I had applied the same principles of <strong>system design</strong> earlier.</p>
<p>In this article, we’re going to explore real-world system design examples from domains like gaming and job platforms. These industries don’t just scale massively – they also demand high availability, low latency, and seamless customer experiences. Understanding how they’re built is a powerful way to level up your thinking as a developer or architect.</p>
<h3 id="heading-what-well-cover">What We’ll Cover</h3>
<ol>
<li><p><a class="post-section-overview" href="#heading-introduction-what-is-system-design-and-why-scale-matters">Introduction: What is System Design and Why Scale Matters</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-approaches-to-system-design">Approaches to System Design</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-1-bottom-up-approach">1. Bottom-Up Approach</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-2-top-down-approach">2. Top-Down Approach</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-3-hybrid-design">3. Hybrid Design</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-important-concepts-in-system-design">Important Concepts in System Design</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-full-stack-web-application-components">Full Stack Web Application Components</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-computers-talk-to-each-other-the-internet">How Computers Talk to Each Other (The Internet)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-the-problem-of-growth">The Problem of Growth</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-speeding-up-your-website-with-caching-and-cdns">Speeding Up Your Website with Caching and CDNs</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-building-your-application-monolith-vs-microservices">Building Your Application: Monolith vs. Microservices</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-the-apis">The APIs</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-handling-real-time-data">Handling Real-Time Data</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-databases">Databases</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-understanding-the-cap-theorem">Understanding the CAP Theorem</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-rate-limiting-and-monitoring">Rate Limiting and Monitoring</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-case-studies-scaling-in-the-real-world">Case Studies: Scaling in the Real World</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-case-study-1-scaling-a-job-search-application">Case Study 1: Scaling a Job Search Application</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-case-study-2-scaling-an-online-gaming-application">Case Study 2: Scaling an Online Gaming Application</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-qampa">Q&amp;A</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-final-notes">Final Notes</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ol>
<h2 id="heading-introduction-what-is-system-design-and-why-scale-matters">Introduction: What is System Design and Why Scale Matters</h2>
<p><strong>System design</strong> is the process of defining the architecture, modules, interfaces, and data of a system.</p>
<p>In other words, system design means explaining the different parts of a system, like its structure, building blocks (modules), and components.</p>
<p>It’s a process used to define, develop, and design a system in a way that meets the specific needs of a business or organisation.</p>
<p>The main goal of system design is to give enough information and details about the system, and to properly implement its parts using models and views. Let’s now talk about the different parts of a system.</p>
<h3 id="heading-elements-of-a-system">Elements of a System:</h3>
<ul>
<li><p><strong>Architecture:</strong> This is a basic structure or model that shows how the system works, looks, and behaves.<br>  We often use <strong>flowcharts</strong> to explain and represent this architecture.</p>
</li>
<li><p><strong>Modules:</strong> These are smaller parts or sections of the system. Each module handles a specific task. When all modules are combined, they make the complete system.</p>
</li>
<li><p><strong>Components:</strong> These provide a specific function or a group of related functions. Components are usually made from one or more modules.</p>
</li>
<li><p><strong>Interfaces:</strong> This is the connection point where different parts (components) of the system exchange information with each other.</p>
</li>
<li><p><strong>Data:</strong> This refers to managing information and how it flows through the system.</p>
</li>
</ul>
<h3 id="heading-why-system-design-matters">Why System Design Matters</h3>
<p>System design is important for a number of practical reasons. First, it can help companies and teams solve complex business problems and make sure they thoroughly analyse all requirements before building. It also reduces the chance that errors will be introduced into processes while making design phases more efficient and structured. Finally, it helps you efficiently gather and present your data in a useful format and improves the overall quality of the system.</p>
<h2 id="heading-approaches-to-system-design">Approaches to System Design</h2>
<p>There are several methods you can use to approach system design. The main ones are:</p>
<h3 id="heading-1-bottom-up-approach">1. Bottom-Up Approach</h3>
<p>In this method, the design starts from the lowest-level components or subsystems. These small parts are gradually combined to form higher-level components. This process continues until the entire system is built as one complete structure.</p>
<p>The more abstraction we use, the higher the level of the design becomes.</p>
<p><strong>Advantages:</strong></p>
<ul>
<li><p>Components can be reused in other systems.</p>
</li>
<li><p>It’s easier to identify risks early.</p>
</li>
<li><p>It helps in hiding low-level technical details and can be combined with the top-down approach.</p>
</li>
</ul>
<p><strong>Disadvantages:</strong></p>
<ul>
<li><p>It’s not very focused on the overall structure of the problem.</p>
</li>
<li><p>Building high-quality bottom-up solutions is hard and time-consuming.</p>
</li>
</ul>
<h3 id="heading-2-top-down-approach">2. Top-Down Approach</h3>
<p>Here, the design starts from the entire system, and you break it down into smaller subsystems and components as you go. Each of these subsystems then gets broken down further, step by step, creating a hierarchical structure.</p>
<p>In simple terms, you start with the big picture and keep dividing it until you reach the smallest parts of the system.</p>
<p>To sum up, design starts with defining the whole system, then continues by defining its subsystems and components. When all definitions are ready and fit together, the system is complete.</p>
<p><strong>Advantages</strong>:</p>
<ul>
<li><p>The focus is on understanding the requirements first, which leads to a responsive and purpose-driven design.</p>
</li>
<li><p>It’s easier to handle errors in interfaces between components.</p>
</li>
</ul>
<p><strong>Disadvantages</strong>:</p>
<ul>
<li><p>Components can’t be reused easily in other systems.</p>
</li>
<li><p>The resulting architecture is often less flexible or not very clean.</p>
</li>
</ul>
<h3 id="heading-3-hybrid-design">3. Hybrid Design</h3>
<p>The hybrid design approach is a mix of <strong>top-down</strong> and <strong>bottom-up</strong> methods. Instead of committing to just one way, it takes the strengths of both. You start by looking at the overall system (like in top-down) so that you don’t lose sight of the big picture. At the same time, you also focus on building solid, reusable modules or components (like in bottom-up).</p>
<p>In simple terms, you first plan the big picture, then create smaller components that can work independently, and finally combine everything into a cohesive system.</p>
<p>For instance, in our sports team site, we’d use top-down to define the whole fan journey (homepage → match details → live scores). But bottom-up, we’d build modular components like authentication or stats tracking, which can later be reused in new features like ticket booking or merchandise sales.</p>
<p><strong>Advantages:</strong></p>
<ul>
<li><p>You get the clarity of a top-down plan while still building reusable modules.</p>
</li>
<li><p>It strikes a balance between high-level design and detailed implementation.</p>
</li>
<li><p>Risks are easier to manage since you’re considering both structure and components.</p>
</li>
</ul>
<p><strong>Disadvantages:</strong></p>
<ul>
<li><p>It can be complex to manage since you’re juggling two approaches.</p>
</li>
<li><p>Requires more coordination between teams working on different levels.</p>
</li>
<li><p>It might take more time compared to using a single approach.</p>
</li>
</ul>
<h2 id="heading-important-concepts-in-system-design">Important Concepts in System Design</h2>
<p>Before exploring core components, I want you to first understand two key concepts:</p>
<ul>
<li><p>Full stack web application components</p>
</li>
<li><p>How computers talk to each other (via the internet)</p>
</li>
</ul>
<h3 id="heading-full-stack-web-application-components">Full Stack Web Application Components</h3>
<p>A full-stack web application is a software application that combines both the frontend (what users see and interact with) and the backend (the server, database, and logic that power the app) into one complete system.</p>
<p>Generally, simple websites don’t require much system design – and in some cases, no system design at all. But when it comes to viral applications or platforms offering complex services, system design becomes essential. Most modern applications are full-stack applications, meaning they involve multiple interconnected layers working together.</p>
<p>Here’s a simplified overview of a typical full-stack application:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755603745131/1114a65f-ea7c-4e3f-aca6-4821c8ca683a.png" alt="full stack web overview" width="1920" height="1080" loading="lazy"></p>
<p>Before diving deep into each of these components, let me first give you a quick, high-level overview of what they are and how they fit into the bigger picture (starting from the bottom of the image above).</p>
<ul>
<li><p><strong>Frontend</strong> – The user interface where people interact with your application.</p>
</li>
<li><p><strong>Backend</strong> – The logic and brain of the application that processes requests.</p>
</li>
<li><p><strong>APIs</strong> – The bridge that allows communication between frontend, backend, and external services.</p>
</li>
<li><p><strong>Database</strong> – The storage system where all your structured information lives.</p>
</li>
<li><p><strong>Server</strong> – The infrastructure that hosts, runs, and delivers your application.</p>
</li>
</ul>
<p>Now, we need to understand how computers talk to each other.</p>
<h3 id="heading-how-computers-talk-to-each-other-the-internet">How Computers Talk to Each Other (The Internet)</h3>
<p>When you type a website's URL into the browser – and this site could be a simple portfolio site or a full stack app – how does your computer know where to send the request? It uses the <a target="_blank" href="https://www.freecodecamp.org/news/what-is-dns/"><strong>Domain Name System</strong></a> <strong>(DNS)</strong>. The DNS is like a phonebook for the internet – it translates a human-readable website name, like "example.com," into a unique numeric IP address that computers can understand.</p>
<p>Once your computer has the IP address, it uses <strong>communication protocols</strong> to send and receive data. One of the most important protocols is <a target="_blank" href="https://www.freecodecamp.org/news/tcp-vs-udp/"><strong>TCP</strong></a>. It breaks data into small, numbered packets. If a packet gets lost or arrives out of order, TCP ensures it's resent and reassembled correctly, making it a very reliable way to send data.</p>
<p>On top of TCP, we use higher-level protocols like <a target="_blank" href="https://www.freecodecamp.org/news/what-is-http/"><strong>HTTP</strong></a>. This is an application-level protocol that's easier for developers to use. It's the language your browser speaks to the server.</p>
<p><strong>HTTPS</strong> is the same, but it adds an extra layer of encryption for security.</p>
<p>Now that we understand the basics of the Internet, remember that it serves billions of people worldwide.</p>
<p>Let’s break this down with a real-life example. Imagine you own a restaurant with a seating capacity of 50 people. One day, 10 extra guests arrive – and with a bit of adjustment, you still manage. But suddenly, a thousand more people show up at your door. What would you do then? It’s not just about adding more chairs and tables anymore – you’ll need extra food supplies, more staff, and a bigger setup to handle such massive traffic.</p>
<p>This simple example reflects the real challenge of growth and scalability. And that’s exactly what I’ll be diving into in the next chapter of this tutorial.</p>
<h3 id="heading-the-problem-of-growth">The Problem of Growth</h3>
<p>Imagine you've built a simple website for a local sports team. Initially, it's just you and a few friends using it, so a single server is sufficient. This server holds all the website's logic and connects to a single database where player stats are stored.</p>
<p>As the team becomes more popular, though, more people visit your site, and it suddenly becomes slow. This is a <strong>scaling issue</strong>. Your system can't handle all the new traffic.</p>
<h4 id="heading-scaling-your-system-two-main-ways">Scaling Your System: Two Main Ways</h4>
<p>There are two ways to solve this. The first is <strong>vertical scaling</strong>. This is like giving your one server a bigger engine and more memory. You'd upgrade the CPU (the brain) or add more RAM (temporary memory). You could also use a faster disk storage like an SSD.</p>
<p>The problem is, you can only upgrade so much before you hit the limits of what's available. Plus, if that single server fails, your entire website goes down.</p>
<p>A better approach is <strong>horizontal scaling</strong>. This means adding more servers instead of just upgrading one. Now you have a team of servers, and each can handle a portion of the incoming user requests.</p>
<p>This approach allows for almost unlimited growth. It also creates redundancy and fault tolerance, because if one server breaks, the others can pick up the slack, and your site stays online.</p>
<h4 id="heading-directing-traffic-with-a-load-balancer">Directing Traffic with a Load Balancer</h4>
<p>With multiple servers, you need a way to make sure no single server gets overwhelmed. This is where a <strong>load balancer</strong> comes in. It acts like a traffic cop, sitting in front of your servers and directing each new request to the best-suited server. It uses different algorithms to decide where to send the traffic.</p>
<p>For example, the <strong>Round Robin</strong> method sends requests to servers one by one, in a cycle. Another method is <strong>Least Connection</strong>, which sends the request to the server that has the fewest active connections.</p>
<h3 id="heading-speeding-up-your-website-with-caching-and-cdns">Speeding Up Your Website with Caching and CDNs</h3>
<p>Imagine your website is now used by people all over the world. A user in another country might experience slow loading times because their request has to travel all the way to your servers.</p>
<p>To fix this, you can use a <a target="_blank" href="https://www.freecodecamp.org/news/how-cdns-improve-performance-in-front-end-projects/"><strong>Content Delivery Network (CDN)</strong></a>. A CDN is a network of servers around the world that store copies of your website's static files – like images, videos, and text files. When a user requests one of these files, the CDN serves it from the closest server, making the website load much faster for them.</p>
<p>This process is a form of <strong>caching</strong>. Caching is the general idea of making copies of data and storing them in a faster-to-access location. You can cache data on your server so it doesn't need to fetch the same player stats from the database every time. This reduces the load on your database and speeds up the entire application.</p>
<p>You can read more about the <a target="_blank" href="https://www.freecodecamp.org/news/caching-vs-content-delivery-network/">difference between CDNs and caching here</a>.</p>
<h3 id="heading-building-your-application-monolith-vs-microservices">Building Your Application: Monolith vs. Microservices</h3>
<p>As your website grows, its code can become a tangled mess. You might start with a <strong>monolith</strong>, where all the features (like player stats and live scores, in our example) are built into a single, large program. <a target="_blank" href="https://www.freecodecamp.org/news/microservices-vs-monoliths-explained/">A monolith is easier to start with</a>, but it can be hard to manage and update.</p>
<p>A better approach for a large-scale application is to use a <a target="_blank" href="https://www.freecodecamp.org/news/the-microservices-book-build-and-manage-services-in-the-cloud/"><strong>microservice architecture</strong></a>. This means breaking your application into smaller, independent services, each with a specific job. For example, one service could handle player stats and another could handle live scores. This makes your code more organised and easier to update, because a change in one service won't affect the others.</p>
<p>With microservices, you need an <a target="_blank" href="https://www.freecodecamp.org/news/what-are-api-gateways/"><strong>API Gateway</strong></a>. This acts as a single entry point for all user requests, directing them to the correct microservice behind the scenes. It also handles security and other common tasks.</p>
<h3 id="heading-the-apis">The APIs</h3>
<p>Think of <strong>APIs (Application Programming Interfaces)</strong> as the “middlemen” that let different pieces of software talk to each other.</p>
<p>In simple terms, an API is like a waiter in a restaurant. You (the user) tell the waiter what you want, the waiter takes your order to the kitchen (the system), and then brings the food (data or result) back to you.</p>
<p>Without APIs, your app, website, or software wouldn’t know how to ask another system for information or services.</p>
<p>For example, on our sports team website:</p>
<ul>
<li><p>The front-end (what fans see) uses an API to <strong>fetch player stats</strong> from the database.</p>
</li>
<li><p>When someone buys match tickets, the API talks to the <strong>payment system</strong> to confirm the transaction.</p>
</li>
<li><p>If fans want live score updates, the API makes sure the real-time data flows smoothly from the server to their screen.</p>
</li>
</ul>
<p>So, APIs are important for system design because they shape how efficiently different systems connect, share data, and stay reliable under real-world use.</p>
<p>Your front-end and back-end services can communicate in several ways. The most common is a <a target="_blank" href="https://www.freecodecamp.org/news/what-is-a-rest-api/"><strong>REST API</strong></a>. It's a standardised set of rules that uses HTTP to create a consistent way for a client and server to talk to each other. For example, it defines a standard way to signal a successful request ("OK") or a server error ("Internal Server Error").</p>
<h4 id="heading-when-to-use-rest">When to use REST</h4>
<ul>
<li><p>Best when: you need simplicity, broad adoption, and easy integration with browsers, mobile apps, or third-party services.</p>
</li>
<li><p>Example: CRUD apps (blogging platforms, e-commerce sites, user management).</p>
</li>
<li><p>Strength: Human-readable JSON, stateless, widely supported.</p>
</li>
<li><p>Weakness: Over-fetching (getting more data than needed) or under-fetching (not enough data).</p>
</li>
</ul>
<p>Another style is <a target="_blank" href="https://www.freecodecamp.org/news/building-consuming-and-documenting-a-graphql-api/"><strong>GraphQL</strong></a>. Instead of getting all the data a REST API provides, GraphQL lets the client ask for only the specific data it needs, which can make things faster and more efficient.</p>
<h4 id="heading-when-to-use-graphql">When to use GraphQL</h4>
<ul>
<li><p>Best when: clients (like mobile apps) need fine-grained control over exactly what data they fetch.</p>
</li>
<li><p>Example: social media feeds, dashboards with lots of widgets, mobile apps with limited bandwidth.</p>
</li>
<li><p>Strength: Flexible queries, reduces over-fetching, strong typing system.</p>
</li>
<li><p>Weakness: More complex server setup, which can cause performance issues if queries aren’t optimised.</p>
</li>
</ul>
<p>For server-to-server communication, <a target="_blank" href="https://www.freecodecamp.org/news/what-is-grpc-protocol-buffers-stream-architecture/"><strong>gRPC</strong></a> is often used. It's known for being very fast because it uses a more efficient data format called Protocol Buffers instead of JSON.</p>
<h4 id="heading-when-to-use-grpc">When to use gRPC</h4>
<ul>
<li><p>Best when: services talk to each other in microservice architectures, and speed/efficiency is critical.</p>
</li>
<li><p>Example: real-time systems (streaming, payments, IoT, machine learning inference).</p>
</li>
<li><p>Strength: Super fast (binary Protocol Buffers), built-in support for streaming, strong contracts.</p>
</li>
<li><p>Weakness: Not browser-native (needs extra tooling for web), harder debugging compared to REST</p>
</li>
</ul>
<p>So to summarize based on my observations of what I have worked on so far:</p>
<ul>
<li><p>If you’re building something <strong>public-facing and widely consumed</strong> → go for REST.</p>
</li>
<li><p>If your app has <strong>complex, dynamic queries from clients</strong> → go for GraphQL.</p>
</li>
<li><p>If you’re dealing with <strong>high-performance internal service-to-service calls</strong> → go for gRPC.</p>
</li>
</ul>
<p>In system design, choosing the right API style directly affects performance, scalability, and user experience. If you pick REST for its simplicity, GraphQL for its flexibility, or gRPC for its speed, you’re shaping how well your system can grow and adapt as real-world demands change.</p>
<h3 id="heading-handling-real-time-data">Handling Real-Time Data</h3>
<p>Real-time data handling is challenging because it requires maintaining an active connection to continuously transmit and receive data simultaneously. Traditional servers follow a request–response model, where data is only sent when explicitly requested.</p>
<p>That's where <a target="_blank" href="https://www.freecodecamp.org/news/learn-websockets-socket-io/"><strong>WebSockets</strong></a> come in. Unlike HTTP, which is a one-and-done request-and-response model, a WebSocket creates a continuous, two-way connection between the client and server. This allows the server to send updates to the user as soon as they happen, creating a real-time experience.</p>
<p>When microservices need to communicate without being directly connected, they can use <a target="_blank" href="https://www.freecodecamp.org/news/how-message-queues-make-distributed-systems-more-reliable/"><strong>message queues</strong></a>. A service sends a message to the queue, and another service picks it up when it's ready. This helps to decouple the services, so they don't have to worry about the other service being available at that exact moment.</p>
<p>On our sports site, WebSockets allow fans to see live scores instantly without refreshing the page – just like in chat apps, but here it keeps the excitement of the game alive in real time</p>
<h3 id="heading-databases">Databases</h3>
<p>Databases are a critical part of any full-stack application because they serve as the permanent home for user data. Once you’ve decided how to scale your servers and manage communication, you also need to consider the database layer. If everything else scales but the database does not, it can quickly become a bottleneck – leading to crashes, inconsistent records, or even data loss.</p>
<p>Many applications rely on <a target="_blank" href="https://www.freecodecamp.org/news/learn-relational-database-basics-key-concepts-for-beginners/"><strong>relational databases (SQL)</strong></a>, which store data in structured tables with rows and columns and are great for handling structured information. But for applications requiring high flexibility or handling massive unstructured datasets, <a target="_blank" href="https://www.freecodecamp.org/news/learn-nosql-in-3-hours/"><strong>NoSQL databases</strong></a> (like MongoDB or Cassandra) are often chosen. These databases don't follow the strict rules of SQL and are better for handling massive amounts of data.</p>
<p>They follow <a target="_blank" href="https://www.freecodecamp.org/news/acid-databases-explained/">ACID properties</a>:</p>
<ul>
<li><p><strong>Atomicity:</strong> A transaction is all or nothing.</p>
</li>
<li><p><strong>Consistency:</strong> The data always remains in a valid state.</p>
</li>
<li><p><strong>Isolation:</strong> Multiple transactions don't interfere with each other.</p>
</li>
<li><p><strong>Durability:</strong> Once a transaction is complete, the data is permanently saved.</p>
</li>
</ul>
<p>Just like with servers, you might need to scale your database. You can use <strong>sharding</strong>, which divides your data across multiple databases, or <strong>replication</strong>, which creates copies of your database to handle more read requests.</p>
<h3 id="heading-understanding-the-cap-theorem">Understanding the CAP Theorem</h3>
<p>When you're dealing with a distributed system and multiple databases, you inevitably face trade-offs. The <strong>CAP Theorem</strong> states that you can only guarantee two out of the following three properties at the same time:</p>
<ul>
<li><p><strong>Consistency</strong> – Every user sees the same, most up-to-date data.</p>
</li>
<li><p><strong>Availability</strong> – The system is always available to respond to requests.</p>
</li>
<li><p><strong>Partition Tolerance</strong> – The system continues to operate even if a part of the network fails.</p>
</li>
</ul>
<p>Now, from a system design perspective, this theorem forces us to make conscious architectural choices. For example, in financial applications (like banking), consistency often takes priority over availability because even a small inconsistency in balance data can cause chaos.</p>
<p>On the other hand, in social media feeds, availability and partition tolerance are often prioritised – it's okay if you see a slightly outdated post, but the system should never be down.</p>
<p>In the flow we’ve been discussing, whenever we introduce a new component or scale out across multiple regions, we need to reassess which two guarantees matter most for our business case. That decision directly drives what database technology we pick, how we design failover strategies, and what trade-offs we accept in user experience.</p>
<p>In short, the CAP theorem isn’t just a theory – it’s a practical compass. It guides us to balance user expectations, business priorities, and technical feasibility without breaking existing functionality, while still leaving room for future growth.</p>
<h3 id="heading-rate-limiting-and-monitoring">Rate Limiting and Monitoring</h3>
<p>When designing a system, it’s not just about making it <em>work</em> – it’s about making it resilient. Two core guardrails here are <strong>rate limiting</strong> and <strong>monitoring</strong>.</p>
<h4 id="heading-what-is-rate-limiting">What is Rate Limiting?</h4>
<p>Rate limiting is the practice of controlling how many requests a user, client, or service can make to your system within a given timeframe. For example, you might cap an API at 100 calls per user per hour. This prevents abuse, safeguards against denial-of-service attempts, and ensures fair usage across all consumers.</p>
<p>Rate limiting comes into play any time your service is exposed publicly or internally to multiple clients.</p>
<p><a target="_blank" href="https://www.freecodecamp.org/news/implement-api-rate-limiting-in-strapi/">To incorporate it</a>, you can implement limits at the API gateway, reverse proxy (like NGINX), or within your service logic itself. Many cloud providers (AWS API Gateway, GCP Endpoints) also have built-in support.</p>
<h4 id="heading-what-is-monitoring">What is Monitoring?</h4>
<p><a target="_blank" href="https://www.freecodecamp.org/news/the-front-end-monitoring-handbook/">Monitoring</a> is the practice of collecting metrics, logs, and traces from your system to understand its health in real time. Typical signals include:</p>
<ul>
<li><p><strong>Error rates</strong> (for example, how often requests fail)</p>
</li>
<li><p><strong>Latency</strong> (how long requests take)</p>
</li>
<li><p><strong>Traffic volume</strong> (load across the system)</p>
</li>
<li><p><strong>Resource utilisation</strong> (CPU, memory, disk, and so on)</p>
</li>
</ul>
<p>Monitoring is important from day one – it’s your feedback loop. Without it, you’re essentially flying blind.</p>
<p>To work it into your system, you can use observability stacks like <a target="_blank" href="https://www.freecodecamp.org/news/kubernetes-cluster-observability-with-prometheus-and-grafana-on-aws/">Prometheus + Grafana</a>, or managed solutions like Datadog, New Relic, or CloudWatch. You can also set alerts for threshold breaches (for example, 5% error rate spike).</p>
<p>In practice, rate limiting and monitoring work hand-in-hand. Rate limiting proactively guards against overload, while monitoring gives you visibility into whether the limits are working, whether scaling is needed, or whether a new type of failure is emerging.</p>
<p>For example, if you’ve designed a booking system (like in our earlier flow), rate limiting would ensure a single user can’t spam seat reservations, while monitoring would flag anomalies such as unusual spikes in request volume or sudden latency increases – helping you act before the system collapses.</p>
<h4 id="heading-why-does-this-matter-for-system-design">Why Does This Matter for System Design?</h4>
<p>These topics matter for good system design because they form the foundational building blocks of how modern applications actually operate in the real world. The way systems communicate, the type of APIs we adopt, and how we manage real-time interactions directly influence whether a product feels fast, reliable, and seamless – or slow and frustrating. In short, they determine how well the overall experience holds up when real users put it to the test.</p>
<p>When we develop a deeper understanding of how computers communicate, we begin to see the inner mechanics of client–server architecture – how APIs fetch data from databases through backend system calls. From this baseline, we can pivot into higher-level concerns:</p>
<ul>
<li><p><strong>Scalability and resilience</strong>: Using load balancers to protect against server overload.</p>
</li>
<li><p><strong>Security</strong>: Introducing rate limiting to mitigate potential cyberattacks.</p>
</li>
<li><p><strong>Efficiency</strong>: Choosing the right type of API calls and leveraging caching/CDNs for speed and reduced overhead.</p>
</li>
<li><p><strong>Reliability</strong>: Implementing logging and monitoring to detect issues early and debug faster.</p>
</li>
</ul>
<p>Together, these practices elevate a system from simply <em>working</em> to being robust, performant, and future-ready.</p>
<p>We’ve discussed the basics of all the most important concepts you’ll need to understand before building an end-to-end system. Now it’s time to deep dive into the case studies, where I’ll show you how different types of applications use system design to scale and serve billions of users.</p>
<p>I have picked services that are complex to build and handle multiple different types of components at a time, like gaming, education, and job search platforms.</p>
<p>Now let’s decode each of them together, and I’ll explain how I would scale the application if I were the developer building it.</p>
<h2 id="heading-case-studies-scaling-in-the-real-world">Case Studies: Scaling in the Real World</h2>
<p>System design is best understood when you see it in action. To show how principles like scaling, caching, load balancing, and real-time data management come together, let’s walk through two very different types of applications:</p>
<ul>
<li><p>A <strong>job search platform</strong> (focused on structured data and reliability).</p>
</li>
<li><p>An <strong>online gaming platform</strong> (focused on real-time speed and responsiveness).</p>
</li>
</ul>
<p>Looking at both will show you that, while the tools and concepts may be similar, the way we apply them depends on the type of system we’re building.</p>
<p>Both are high-traffic platforms, but with totally different needs. The job portal is about accuracy, reliability, and data-driven workflows, while the gaming platform is about instant responsiveness, fairness, and global reach.</p>
<p>In a job portal, a 1-second delay just means waiting. In a gaming app, a 1-second delay could mean losing the match. Both are failures – but for completely different reasons, and with different consequences.</p>
<p>Together, they show how the same building blocks of system design (scaling, caching, APIs, monitoring) are applied differently depending on context.</p>
<h3 id="heading-case-study-1-scaling-a-job-search-application">Case Study 1: Scaling a Job Search Application</h3>
<p>A job search platform is one of the most used applications nowadays, as there are always people looking for a job. And there are many different job portals out there that handle the complete process, from finding jobs to user onboarding.</p>
<p>We’ll look at an example site called <a target="_blank" href="https://upstaff.com/">Upstaff</a>. It’s a platform that focuses on hiring AI engineers as its core service (although it services other job profiles as well). At its core, it handles structured information – things like user profiles, job postings, and applications.</p>
<p>Day one, you have a few hundred users. On day one hundred, you may have tens of thousands. And in a year? Possibly millions. That growth means you have to think about scale, speed, and data integrity from the start.</p>
<h4 id="heading-the-core-components">🔹 The Core Components</h4>
<ul>
<li><p><strong>User Management:</strong> registration, login, and role-based access (job seeker vs employer).</p>
</li>
<li><p><strong>User Profiles</strong>: résumés, skills, preferences, stored in structured databases.</p>
</li>
<li><p><strong>Job Posting and Listings</strong>: employers create jobs, seekers browse/search/filter.</p>
</li>
<li><p><strong>Application Tracking</strong>: Every job seeker’s application status needs to be accurate and up to date.</p>
</li>
<li><p><strong>Recommendation Engine</strong>: jobs matched to users based on history and profile.</p>
</li>
<li><p><strong>Notifications</strong>: alerts for new job matches, recruiter replies, deadlines.</p>
</li>
</ul>
<p>Every one of these features depends on the system’s ability to handle large amounts of structured data – and handle it reliably.</p>
<h4 id="heading-step-1-starting-small">Step 1: Starting Small</h4>
<p>At the beginning, everything can run on one server with a single database. This setup is enough for a few thousand users.</p>
<h4 id="heading-step-2-growth-and-traffic-spikes">Step 2: Growth and Traffic Spikes</h4>
<p>As more users join, the single server starts to slow down. To fix this, we add a load balancer and scale horizontally – adding multiple servers that share the traffic.</p>
<h4 id="heading-step-3-database-challenges">Step 3: Database Challenges</h4>
<p>Soon, the database becomes the bottleneck. Searching across thousands of jobs slows things down. To fix this, we:</p>
<ul>
<li><p>Use sharding (split the database by user IDs or job IDs).</p>
</li>
<li><p>Add a cache (like Redis) to store frequent queries such as “Software Engineer in New York.”</p>
</li>
<li><p>Use a CDN to deliver logos, profile pictures, and other static files faster.</p>
</li>
</ul>
<h4 id="heading-step-4-heavy-features">Step 4: Heavy Features</h4>
<p>New features like a résumé parser or recommendation engine require extra computing power. Instead of overloading the main app, we move these into separate microservices.</p>
<h4 id="heading-step-5-security-and-reliability">Step 5: Security and Reliability</h4>
<p>Finally, as traffic grows, we add:</p>
<ul>
<li><p><strong>Rate limiting</strong> to stop any one user from spamming APIs.</p>
</li>
<li><p><strong>Monitoring</strong> to track errors, latency, and user activity in real time.</p>
</li>
<li><p><strong>API Gateway</strong> to ensure all requests are secure and validated. Here is an overview of the entire system scaling in an image :</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754281195211/570680c1-2813-43b0-87a1-48a817ab6c9a.png" alt="system design job portal flowchart" width="600" height="400" loading="lazy"></p>
<p>This example shows how careful planning makes growth smooth. By scaling horizontally, caching smartly, and splitting heavy features into microservices, a job portal like Upstaff can handle millions of users without breaking.</p>
<h3 id="heading-case-study-2-scaling-an-online-gaming-application">Case Study 2: Scaling an Online Gaming Application</h3>
<p>Now let’s flip the script. In a gaming platform like <a target="_blank" href="https://xn--ntcasinoutanlicens-ltb.com">this site</a>, speed and responsiveness matter more than anything. A 1-second delay in a job search is annoying. But in gaming, a 1-second delay can make players quit forever. Unlike job portals, the biggest challenge here is real-time responsiveness. A tiny delay can ruin the user experience.</p>
<h4 id="heading-the-core-components-1">🔹 The Core Components</h4>
<ul>
<li><p><strong>User Management Service</strong>: accounts, profiles, and login.</p>
</li>
<li><p><strong>Game Lobby and Matchmaking</strong>: pair players by skill, region, and latency.</p>
</li>
<li><p><strong>Game Server Manager</strong>: spin up and manage live matches.</p>
</li>
<li><p><strong>Real-Time Communication</strong>: powered by WebSockets or UDP for low latency.</p>
</li>
<li><p><strong>Game State Store (Redis)</strong>: fast sync of health, scores, and positions.</p>
</li>
<li><p><strong>Leaderboard &amp; Stats Engine</strong>: global rankings, achievements, and progress.</p>
</li>
<li><p><strong>In-Game Economy</strong>: coins, tokens, inventory.</p>
</li>
<li><p><strong>Payment Gateway</strong>: subscriptions and purchases.</p>
</li>
<li><p><strong>Anti-Cheat Security Layer</strong>: fairness across all players.</p>
</li>
<li><p><strong>Monitoring and Logging</strong>: server uptime, latency, and crash reports.</p>
</li>
</ul>
<p>Unlike a job portal, every millisecond counts.</p>
<h4 id="heading-step-1-starting-small-1">Step 1: Starting Small</h4>
<p>At first, one powerful server is enough to run both the game logic and user accounts. With just a few players, things run smoothly.</p>
<h4 id="heading-step-2-more-players-more-problems">Step 2: More Players, More Problems</h4>
<p>As millions of players log in, the single server crashes. To fix this, we:</p>
<ul>
<li><p>Add a Game Server Manager that spins up separate servers for each match.</p>
</li>
<li><p>Introduce a load balancer that assigns players to available servers.</p>
</li>
</ul>
<h4 id="heading-step-3-real-time-data-handling">Step 3: Real-Time Data Handling</h4>
<p>In gaming, speed is everything. Instead of slow HTTP, we switch to WebSockets or UDP for instant communication. To keep everyone’s game view in sync:</p>
<ul>
<li><p>Use in-memory databases like Redis for positions, scores, and health.</p>
</li>
<li><p>Update leaderboards in near real time.</p>
</li>
</ul>
<h4 id="heading-step-4-scaling-features">Step 4: Scaling Features</h4>
<p>Other services run in parallel:</p>
<ul>
<li><p><strong>Matchmaking service</strong> pairs players by skill, location, and latency.</p>
</li>
<li><p><strong>Economy service</strong> manages coins, rewards, and in-game items.</p>
</li>
<li><p><strong>Payment gateway</strong> handles subscriptions and purchases securely.</p>
</li>
<li><p><strong>Notification system</strong> sends updates like “new event starting.”</p>
</li>
</ul>
<h4 id="heading-step-5-global-expansion-and-security">Step 5: Global Expansion and Security</h4>
<p>When the game expands worldwide:</p>
<ul>
<li><p>Use a CDN to deliver maps and skins quickly to all regions.</p>
</li>
<li><p>Add an Anti-Cheat layer to detect and block unfair play.</p>
</li>
<li><p>Build an Admin and Monitoring panel to track system health and user behavior.</p>
</li>
</ul>
<p>In gaming, system design focuses less on structured data and more on low latency, real-time communication, and fairness. Scaling here means keeping gameplay smooth and secure, even when millions of players join at once. Here is the image representation of the complete game platform system design</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754287625776/546f3949-efa1-4a57-9906-ceb3f8a62f63.png" alt="system design game website flowchart" width="1920" height="1080" loading="lazy"></p>
<h3 id="heading-why-both-case-studies-matter">Why Both Case Studies Matter</h3>
<p>You might wonder – why show two different systems instead of just one? The answer is that system design isn’t “one-size-fits-all.”</p>
<ul>
<li><p>The job portal teaches us how to scale structured, data-heavy applications where reliability and accuracy matter most.</p>
</li>
<li><p>The gaming platform shows us how to design for speed, real-time communication, and fairness under extreme load.</p>
</li>
</ul>
<p>Together, these examples prove that the same system design principles of scaling, caching, monitoring, and microservices apply everywhere. What changes is <em>how you use them</em> to solve the unique challenges of your platform.</p>
<h2 id="heading-qampa">Q&amp;A</h2>
<h3 id="heading-how-to-get-into-system-design-if-you-dont-understand-anything-yet"><strong>How to get into system design if you don’t understand anything (yet)?</strong></h3>
<p>I get this question all the time – and the first thing you need to know is that system design isn’t some separate, elite domain. It’s an <em>additional skill</em> that complements your development journey.</p>
<p>If you're a full-stack developer (or aiming to be one), learning system design gives you a huge edge. After all, building an app isn't just about making it work – it’s about making it <em>work well</em> at scale.</p>
<p>So if you’re just starting and don’t even know how to become a full-stack developer yet, start there. Learn to build applications first, and then system design will start making a lot more sense. Read this guide <a target="_blank" href="https://www.freecodecamp.org/news/become-a-full-stack-developer-and-get-a-job/">How to Become a Full-Stack Developer in 2025 (and Get a Job) – A Handbook for Beginners</a> to learn how to become a full-stack developer.</p>
<h3 id="heading-how-do-you-understand-system-design-concepts"><strong>How do you understand system design concepts?</strong></h3>
<p>The short answer: with time and consistent practice.</p>
<p>Think of it like this: if you know how to use a pencil, it’s up to you whether you use it to sketch or to write. The pencil is just a tool. Similarly, in system design, once you understand the core concepts, it’s about knowing <em>when</em> and <em>where</em> to apply them. The rest – frameworks, tools, and technologies – are just means to an end.</p>
<p>It’s not about memorising patterns, it’s about developing the instinct to use the right building blocks at the right time.</p>
<h3 id="heading-what-tools-should-you-know-before-diving-into-system-design">What tools should you know before diving into system design?</h3>
<p>The truth is, the list keeps growing. New tools and platforms are constantly emerging. But in my experience, having a solid foundation in the following areas makes a huge difference:</p>
<ul>
<li><p><strong>Full Stack Development</strong> – so you understand how both frontend and backend systems interact.</p>
</li>
<li><p><strong>Cloud Platforms</strong> (like AWS, GCP, or Azure) – because most modern systems are cloud-native.</p>
</li>
<li><p><strong>CI/CD Pipelines</strong> – for automating testing, integration, and deployment.</p>
</li>
<li><p><strong>Deployment Strategies</strong> – to know how to roll out new changes with minimal risk.</p>
</li>
</ul>
<p>Mastering these gives you the technical muscle to design systems that are scalable, reliable, and production-ready. I am a frontend developer, why should I know the system design</p>
<h3 id="heading-what-resources-should-i-study-to-learn-system-design">What resources should I study to learn system design?</h3>
<p>In my last <a target="_blank" href="https://www.freecodecamp.org/news/become-a-full-stack-developer-and-get-a-job">article</a>, I shared all the resources that helped me learn system design.</p>
<p>System design is crucial for building reliable, high-performance applications. I explored the following resources:</p>
<ul>
<li><p><a target="_blank" href="https://github.com/donnemartin/system-design-primer"><strong>Free GitHub system design repositor</strong></a><strong>y</strong></p>
</li>
<li><p><a target="_blank" href="https://github.com/ByteByteGoHq/system-design-101"><strong>Another free GitHub system design repositor</strong></a><strong>y</strong></p>
</li>
<li><p><a target="_blank" href="https://www.systemdesignhandbook.com/system-design-interview-handbook/">Free System Design Handbook</a></p>
</li>
<li><p><a target="_blank" href="https://grokkingthesystemdesign.com/intro-to-system-design/">Free Hands-on System Design Learning Platform</a></p>
</li>
<li><p><a target="_blank" href="https://www.educative.io/guide/system-design">Free Intro to System Design Blog</a></p>
</li>
</ul>
<p>Case studies and real-world architectures can also help you understand large-scale systems. You can follow any big tech engineering blog (Uber has a great one).</p>
<p>For high-level concepts, I went through the <a target="_blank" href="https://www.educative.io/courses/grokking-the-system-design-interview"><strong>Grokking System Design</strong></a> course. It’s a paid resource, and I used it to deepen my understanding of system design. It’s not mandatory, but it helped me think about architecture at scale.</p>
<p><strong>Note:</strong> there are other sites and courses out there of course, but I only share what I have personally experienced and used, and I focus on FREE material first.</p>
<h3 id="heading-where-to-practice-system-design">Where to practice system design</h3>
<p>This is where real learning begins. Start by picking any existing application from the internet, just like I did. Google something specific, like “job application portal,” but avoid the results on the first page. Those apps are usually well-optimised and already follow best practices in system design.</p>
<p>Instead, dig deeper and explore results from the second or third page. Look for an app that seems to be in its early stages.</p>
<p>Once you find one, try to understand how the entire application works. Break it down into its core components and then imagine what would happen if that app started receiving 1 million users a day. You’ll naturally begin to see what system design elements are needed to handle that kind of load.</p>
<h2 id="heading-final-notes">Final Notes</h2>
<p>Learning system design becomes much easier when you’ve already built something. Let’s say you’ve created an app and now you're thinking about how to scale it – that’s where real learning begins. The moment you start writing down your requirements (like how your app should behave when it starts getting more traffic), you naturally begin to develop system-level thinking. It’s this process of planning and anticipating real-world usage that turns theory into a practical skill.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Full Stack + System Design = The Ultimate Developer Stack 🔥</p>
<p>By mastering these skills, you can turn any idea into a real-world product, secure high-paying jobs, and even start your tech venture.</p>
<p>Now it's your turn – what are you building next? Let me know!</p>
<p>That’s all from my side. If you found this article helpful, feel free to share it and connect with me. I’m always open to new opportunities:</p>
<ul>
<li><p>Follow me on X: <a target="_blank" href="https://x.com/prankurpandeyy">Prankur's Twitter</a></p>
</li>
<li><p>Connect with me on LinkedIn: <a target="_blank" href="https://linkedin.com/in/prankurpandeyy">Prankur's LinkedIn</a></p>
</li>
<li><p>Follow me on GitHub: <a target="_blank" href="https://github.com/prankurpandeyy">Prankur’s Github</a></p>
</li>
<li><p>View my Portfolio: <a target="_blank" href="https://prankurpandeyy.netlify.app/">Prankur's Portfolio</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ High Availability vs Fault Tolerance vs Disaster Recovery – Explained with an Analogy ]]>
                </title>
                <description>
                    <![CDATA[ High availability, fault tolerance and disaster recovery are important things to consider when designing a system. These terms are sometimes used interchangeably by architects and developers. They are not, however, the same thing – and understanding ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/high-availability-fault-tolerance-and-disaster-recovery-explained/</link>
                <guid isPermaLink="false">66d45e10f855545810e9342b</guid>
                
                    <category>
                        <![CDATA[ availability ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Disaster recovery ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software architecture ]]>
                    </category>
                
                    <category>
                        <![CDATA[ System Architecture ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Daniel Adetunji ]]>
                </dc:creator>
                <pubDate>Mon, 07 Nov 2022 17:10:24 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/11/Slide6.JPG" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>High availability, fault tolerance and disaster recovery are important things to consider when designing a system.</p>
<p>These terms are sometimes used interchangeably by architects and developers. They are not, however, the same thing – and understanding the differences can save you many headaches, as well as time and money.</p>
<p>This article will go through the differences between the three terms and explain how you can implement them in AWS.</p>
<h2 id="heading-highly-available-vs-fault-tolerant-vs-disaster-recovery">Highly Available vs Fault Tolerant vs Disaster Recovery</h2>
<p>A highly available system is one that aims to be online as often as possible. While downtime can still occur in a highly available system, the aim of high availability is to limit the duration of the downtime, not to completely eliminate it.</p>
<p>A fault tolerant system is one that can operate through a fault without any downtime. Fault tolerance aims to avoid downtime completely.</p>
<p>In a complete system failure however, high availability and fault tolerance are not enough. Disaster recovery describes how the system can continue to operate when the cushion of high availability and fault tolerance disappears in a system wide failure.</p>
<h2 id="heading-what-does-high-availability-mean">What Does High Availability Mean?</h2>
<p>First, let's describe what high availability is not. High availability does not mean that the system never fails or never experiences downtime. A highly available system is simply one that aims to be online as often as possible.</p>
<p>Imagine we have a pizza restaurant that is open 24 hours every day for 365 days. If that restaurant only has one chef, then its availability – that is, its ability to process orders – will not be 100%. This is because a single chef can only work for about eight hours a day with a one hour break – or effectively seven hours a day, for seven days in a week.</p>
<p>The chef can therefore only work for 49 hours in a week out of a possible 168 hours. This restaurant has an availability of 29%.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3e3d174-070d-447d-9088-92c6f7377c99_1504x861.jpeg" alt="Image" width="1456" height="834" loading="lazy"></p>
<p><em>A low availability restaurant</em></p>
<p>This is of course not a high enough availability for a restaurant that wants to be open for 24 hours in a day throughout the year.</p>
<p>So how do we get a higher availability for the restaurant? Hire more chefs. If we have four chefs working six hour shifts in a day for seven days in a week, this gives us a theoretical availability of 100%.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8b1538ad-5148-44f1-b025-c6705a5c3780_1504x830.jpeg" alt="Image" width="1456" height="804" loading="lazy"></p>
<p><em>A higher availability restaurant</em></p>
<p>This 100% availability is only theoretical because it assumes no chef misses work in an entire year. This is a poor assumption as chefs can get sick, their cars can break down on the way to work, or they may have to leave work early to pick up their kids.</p>
<p>Let's say all this chef downtime adds up to five hours in a year. This gives you an availability of 99.94%.</p>
<p>How can you make the restaurant even more available? Hire standby chefs that are ready to come to the restaurant at a moment's notice. But this comes at a steep price since you have to pay these chefs to wait until they are needed.</p>
<p>What these standby chefs give you is <strong>the ability to quickly recover from not having enough chefs to meet customer orders</strong>. You can never have 100% availability because of the constraints of reality. You can only approach an availability of 100% at an increasingly steep price.</p>
<h3 id="heading-what-is-availability-in-a-system">What is Availability in a System?</h3>
<p>Availability is the probability that a system will be able to respond to a request.</p>
<p>Note that high availability has nothing to say about the quality of the pizzas or how quickly they are delivered. High availability is simply concerned with the ability of the restaurant to respond to pizza orders from customers.</p>
<p>The major cloud providers typically have <a target="_blank" href="https://www.cio.com/article/274740/outsourcing-sla-definitions-and-solutions.html">SLAs</a> that describe the availability of a system.</p>
<p>Take a blob storage system, for example. AWS S3 standard has an availability SLA of 99.99%. This is the same figure for Azure blob storage and Google cloud storage.</p>
<p>What exactly does 99.99% availability mean? It means that in any year, there is a 99.99% probability that the system will be online. An uptime of 99.99% equals a downtime of 0.01%. This is equivalent to a downtime of approximately 53 minutes - just under an hour for an entire year.</p>
<p>How about an availability of 99.9%? Such a system would have a downtime of 0.1% which is 8.8 hours in a year.</p>
<p>While 99.9% availability may seem high, for a bank processing payments, air traffic control system, or any other critical system, such amount of downtime may simply be unacceptable.</p>
<p>What is the right amount of availability you should target? That depends on the requirements of the system you are building.</p>
<p>You are of course constrained by the availability SLAs of the cloud providers, so there is limited flexibility in achieving say 99.999% availability for a blob storage system, for example. And, the higher the availability you want to achieve, the more expensive and complex the solution becomes.</p>
<h2 id="heading-what-does-fault-tolerance-mean">What Does Fault Tolerance Mean?</h2>
<p>If a failure within a system occurs, can the system continue to operate without any disruption? If it can, then the system is fault tolerant.</p>
<p>So what is the difference between high availability and fault tolerance? With a highly available system, failures that cause downtime will occur, but rarely. The system is also able to recover from such failures. <strong>But when the system is down, it cannot respond to requests.</strong></p>
<p>In a fault tolerant system, the system <strong>can continue to operate in spite of a failure.</strong></p>
<p>Let's use the pizza restaurant as an example again. If the restaurant experiences a power outage, then no amount of chefs in the kitchen or chefs on standby will help with making pizzas for customers since the ovens need a power supply.</p>
<p>A backup generator that kicks in immediately when a power loss is experienced makes the restaurant fault tolerant.</p>
<p>Another good example of this is a commercial aircraft powered by jet engines. These aircraft are built to be fault tolerant so in the event that one engine fails, the aircraft can continue to fly and land without disruption or having to fix the failed engine in flight.</p>
<p>Helicopters or single engine aircraft, on the other hand, are not fault tolerant. A failure of the engine means the aircraft cannot fly. Such failures are usually catastrophic and partly explain the higher rate of helicopter and single engine aircraft crashes compared to dual engine aircraft.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfafca0a-1940-4215-ac2b-39a7a84b9660_1504x861.jpeg" alt="Image" width="1456" height="834" loading="lazy"></p>
<p><em>An aircraft with two engines is fault tolerant</em></p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F964241a9-8fc6-4d65-86c2-48f509a5951a_1504x861.jpeg" alt="Image" width="1456" height="834" loading="lazy"></p>
<p><em>Helicopters and single engine aircraft are not fault tolerant</em></p>
<h2 id="heading-what-does-disaster-recovery-mean">What Does Disaster Recovery Mean?</h2>
<p>If the scale of the system failure is so large that the high availability and fault tolerance of the system are effectively neutralised, can the system continue to operate?</p>
<p>Let's go back to the restaurant example. If a fire, flood, or any other disaster befalls your pizza restaurant, how can you continue to make pizzas for your customers?</p>
<p>This is a somewhat facetious example since in the event of a fire, worrying about customer orders is not the main priority – but the logic of the example still holds.</p>
<p>In this instance, high availability is of no help. Having an infinite number of chefs in the kitchen or on standby in a restaurant engulfed in flames = no pizzas for customers.</p>
<p>Fault tolerance is also of no help. A backup generator is useless for the appliances it is meant to power if they have been destroyed.</p>
<p>The only way the system (restaurant) can continue to operate is by routing orders to another nearby restaurant unaffected by the fire. Disaster recovery is a proactive plan of action that details how to recover <strong>after a disaster has happened</strong>.</p>
<h2 id="heading-bringing-it-all-together">Bringing it All Together</h2>
<p>Now, let's look at a single architecture that is simultaneously highly available, fault tolerant, and has built-in disaster recovery.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3995b811-f03f-44b5-8118-8f7965e7f09a_893x560.jpeg" alt="Image" width="893" height="560" loading="lazy"></p>
<p><em>All in one - high availability, fault tolerance, and disaster recovery in a single architecture</em></p>
<p>The architecture above shows a multi-availability zone (AZ) Relational Database Service (Amazon RDS) deployment. It shows an RDS database with a standby instance in a separate AZ, a single read-only replica, and an S3 bucket used to store backups of the database on a daily basis.</p>
<p>This RDS is a fully managed DB as a service offering from AWS where AWS manages the underlying hardware, software, and application of the DB. You can find more information here on <a target="_blank" href="https://aws.amazon.com/rds/">AWS RDS</a> and <a target="_blank" href="https://aws.amazon.com/about-aws/global-infrastructure/regions_az/">availability zones</a>.</p>
<p>Now let's dissect how this system would work and how the design ensures it is highly available, fault tolerant and can recover from a disaster.</p>
<h3 id="heading-how-high-availability-is-achieved">How High Availability is Achieved</h3>
<p>The primary RDS instance in AZ A synchronously replicates its data to the standby instance in AZ B.</p>
<p>With synchronous replication, the primary instance waits until the standby has received the latest write operation before the transaction is recorded as successful. This ensures that both databases have identical information – that is, they are consistent, admittedly at the expense of increased transaction latency.</p>
<p>The primary and standby instances are in an active-passive configuration. Only the primary receives read and write request. The job of the standby is to simply take over as the primary in the event of a failure of the primary instance.</p>
<p>The time it takes to failover from the primary to the standby instance is called the Recovery Time Objective (RTO). The RTO simply describes how long it takes to recover from a failure. In this case, the failover time for RDS in a multi-AZ configuration is currently between 1-2 minutes.</p>
<p>The standby instance has one purpose: to increase the availability of the system. If the primary instance fails, or if the entire AZ A goes down, the standby instance in a separate AZ will be promoted to the primary. This failover process takes 1-2 minutes. That is 1-2 minutes of downtime.</p>
<p>Recall that high availability is not about preventing downtime, but simply reducing it. Without a standby instance, there is a high probability that downtime will exceed the 1-2 mins it takes to recover with a standby instance.</p>
<p>Note that the standby instance does not help with fault tolerance, since the failure of the primary will still lead to downtime.</p>
<h3 id="heading-how-fault-tolerance-is-achieved">How Fault Tolerance is Achieved</h3>
<p>To eliminate downtime, you need a configuration that involves no failover. This is a job for read-only replicas. These are asynchronously replicated copies of the primary instance. Writes are only made to the primary instance. Read replicas are, as the name implies, read only.</p>
<p>Such an approach is ideal for read heavy application since read replicas can remove the additional burden of read requests from the primary instance.</p>
<p>In asynchronous replication, writes to a primary instance do not wait for a response from the read-only replica before the transaction is recorded as a success. This means that, for a time, data across the primary and read replica may not be identical (but rather, inconsistent) after a write to the primary.</p>
<p>This eventual consistency (a topic for another article) is a drawback of asynchronous replication. The benefit of asynchronous replication is that it does not wait for the read replica to respond before the transaction is recorded as a success.</p>
<p>This is important because if the read replica is down or there is a network failure, the primary can still accept subsequent writes without waiting for a response from the read replica, confirming that the previous write was successfully replicated.</p>
<p>The architecture above has two replicas: one synchronous and the other asynchronous. If all replicas are synchronous, then a failure in the standby replica or the read only replica, or even a network failure, brings the entire cluster down. This is a fragile design that exposes the entire system to failure if a single component fails. Having some replicas that are synchronous and others that are asynchronous improves the fault tolerance of the system.</p>
<p>Where else does fault tolerance come in? Like an aircraft with two jet engines that provide thrust, a read replica and a primary can work together simultaneously. The the primary instance processes writes and the read replica responds to read requests.</p>
<p>Failure of the primary instance has no effect on the read replica's ability to respond to read requests. There is no downtime for reads since only the read replica responds to reads.</p>
<p>How about writes? The read replica can be promoted to a primary, although with RDS, this is currently a manual process.</p>
<h3 id="heading-how-disaster-recovery-is-achieved">How Disaster Recovery is Achieved</h3>
<p>With the architecture above, you can handle disaster recovery in two ways. There is no constraint to limit disaster recovery to only one approach, so you can use both at the same time. And in fact, the more approaches you have, the better, since this provides extra redundancy.</p>
<p>Ultimately, you should weigh all this against cost, as implementing disaster recovery strategies can be expensive.</p>
<p>The first method is through automatic backups. Backups are taken from the standby instance, preventing performance degradation of the primary instance that has to serve writes (and reads if not configured with a read replica). Since there is synchronous replication between the primary and the standby, we have a guarantee that the standby is an up to date copy of the primary, so it's ideal to take backups from.</p>
<p>With RDS, backups are taken on a fixed schedule once a day (specified by you) and stored in an S3 bucket. Since this is an entirely separate component, any RDS-related system-wide failures will not affect the durability of the backups.</p>
<p>With backups, a loss of the primary, standby, and read-replicas does not equal a permanent loss of data. Backups can then be used to restore the database to a new DB instance.</p>
<p>The second method is to promote the read-only replica to a standalone instance if the primary instance fails. The read replica can be configured in another <a target="_blank" href="https://aws.amazon.com/about-aws/global-infrastructure/regions_az/">AWS region</a>. This way, if there is a disaster on a regional scale where multiple AZs are down, a cross regional read replica will ensure that another instance is available in a different AWS region to serve read and write requests.</p>
<p>This is analogous to diverting orders to another restaurant in the event of a fire.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb353885-8d22-4542-8155-2f92e3d49314_943x635.jpeg" alt="Image" width="943" height="635" loading="lazy"></p>
<p><em>How different components improve the availability, fault tolerance and disaster recovery of a solution</em></p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>Availability is measured in percentages - the larger the number, the more available the system is (hence less downtime).</p>
<p>Very few systems aim for 100% availability – although pacemakers are a notable exception. An availability of 99.999% has a downtime of 0.001% = 5 minutes of downtime in a year. This tends to be the upper limit for most software systems.</p>
<p>Aiming for higher levels of availability above this is increasingly complicated, expensive, and often unnecessary. This is especially true when you consider that the software system you are building relies on infrastructure like the power grid and internet service providers, which may have lower availability levels.</p>
<p>Fault tolerance, on other hand, cannot be measured. Your design is either fault tolerant or it is not. Similarly, disaster recovery cannot be measured. You either have a plan of action that precisely outlines how your system can recover from a disaster or you do not.</p>
<p>Knowing the difference between high availability, fault tolerance, and disaster recovery is important. It ensures you are building the correct architecture based on customer needs.</p>
<p>Over-engineering a solution by providing disaster recovery when all that is required is high availability or fault tolerance is often an expensive and complex exercise.</p>
<p>On the other hand, under-engineering a solution by only providing high availability when fault tolerance is required can lead to severe consequences for some critical systems that cannot afford any downtime.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ System Design Interview Tutorial – The Beginner's Guide to System Design ]]>
                </title>
                <description>
                    <![CDATA[ By Charles M. System Design is an important topic to understand if you want to advance further in your career as a software engineer. Even if you are just beginning your coding journey, it's a good idea to get a head start on learning about system de... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/system-design-interview-practice-tutorial/</link>
                <guid isPermaLink="false">66d45ddb8812486a37369c75</guid>
                
                    <category>
                        <![CDATA[ beginners guide ]]>
                    </category>
                
                    <category>
                        <![CDATA[ distributed systems ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Interview tips ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Job Interview ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Microservices ]]>
                    </category>
                
                    <category>
                        <![CDATA[ System Architecture ]]>
                    </category>
                
                    <category>
                        <![CDATA[ System Design ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 14 Jun 2021 22:46:31 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/06/youtube-system-design-thumbnail.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Charles M.</p>
<p>System Design is an important topic to understand if you want to advance further in your career as a software engineer. Even if you are just beginning your coding journey, it's a good idea to get a head start on learning about system design. </p>
<p>Early in your career you will mostly just be tested on your coding ability. In higher level interviews, however, there will often be a greater focus on testing your ability and experience at designing applications.</p>
<p>The biggest struggle engineers have with system design interviews is that they are more open-ended and there isn't any single correct answer. This lack of structure can be intimidating, so my goal with this article is to give you a roadmap for navigating these types of interviews with confidence.</p>
<p>What this article will cover:</p>
<ul>
<li>What is a system design interview and why they are used</li>
<li>The main stages of a system design interview</li>
<li>Example interview problem – Design YouTube</li>
</ul>
<h2 id="heading-video-tutorial">Video Tutorial</h2>
<p>You can also watch this tutorial on YouTube if you like:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/YEwKnGARDZI" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>And I've created a playlist of videos on specific topics related to system design and web architecture:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/undefined" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-system-design-interview-overview">System Design Interview Overview</h2>
<p>At first glance it seems silly to ask somebody to design a huge app like Twitter or YouTube in 45-60 minutes. These apps were designed over a period of years by hundreds of engineers working together, so it's clearly an impossible task to do in a short interview.</p>
<p>There are two main reasons why companies use these types of interviews. The first is, of course, to test your knowledge about the technologies being discussed. They want you to go deep enough to make sure you aren't just throwing buzzwords around without understanding how things actually work. </p>
<p>The second reason might be more important, though. The system design interview is a way to simulate a realistic scenario where you are working together with the interviewer to determine the best design decision. </p>
<p>Getting the perfect answer isn't necessarily the most important thing here – it's some of the other things you can show, like:</p>
<ul>
<li>How do you handle being challenged? Do you get defensive or take feedback with a positive attitude? Are you stubborn or narrow-minded?</li>
<li>Do you show knowledge of the various tradeoffs certain design decisions involve? There's a big difference between blindly making a decision and not realizing the consequences, and knowing the pros/cons and accepting the tradeoffs.</li>
<li>Are you able to effectively communicate and if necessary explain complex technical concepts in an easy to understand way?</li>
<li>Are you candidate somebody the interviewer would want to work with long term? Even if somebody is a genius, if they are miserable to work with they might not be a good hire.</li>
</ul>
<h2 id="heading-stages-of-a-system-design-interview">Stages of a System Design Interview</h2>
<p>In this section you'll learn a general framework for structuring how to handle a problem during a system design interview.</p>
<h3 id="heading-clarify-the-problem-and-establish-design-scope">Clarify the problem and establish design scope</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-106.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>The first thing you'll want to do after your interviewer gives you the problem is to take a few minutes to ask some clarifying questions and figure out what exactly they are looking for. </p>
<p>The worst thing you could do here is just start off in the completely wrong direction because you didn't take the time to ask a few questions. You have a limited amount of time during the interview, so you want to make sure you focus on what's important. </p>
<p>Here are some examples of questions you might ask:</p>
<h4 id="heading-what-are-the-use-cases-features-of-the-app">What are the use cases / features of the app?</h4>
<p>In this article we will be using YouTube as an example. There are hundreds of different features you could design like ad delivery, authentication, recommendation algorithms, comments, video upload, video processing, and many others. </p>
<p>During an interview you only have time to cover a few of those, so make sure to ask the interviewer questions to figure out what they want you to focus on designing.</p>
<h4 id="heading-how-many-users-are-expected-what-is-the-likely-traffic-volume">How many users are expected / what is the likely traffic volume?</h4>
<p>The complexity of the system will depend on the amount of traffic it needs to handle, so make sure to gather this information. </p>
<p>You don't want to over-engineer things if the traffic is relatively low and you also don't want to get stuck with an app that can't scale because you didn't design it properly. </p>
<p>Ask questions like how many users the app will have, the average amount of data per request, how long data needs to be stored, and how reliable and available does the system need to be?</p>
<p>This step is going to help you beyond just getting more information to work with. You're also showing the interviewer that you understand how to gather information about a vague problem. </p>
<h3 id="heading-determine-rough-capacity-estimates">Determine Rough Capacity Estimates</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-107.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Using the information you gathered during the first step, you can begin to make some rough estimates and generalizations for things like storage and bandwidth requirements.</p>
<p>This process will involve some basic math like multiplying the number of users by the average request size and the amount of requests each user is expected to make daily. </p>
<h3 id="heading-create-a-high-level-design">Create a High Level Design</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-108.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Here you want to create a rough architecture for the system. Draw out things like load balancers, web servers, app servers, task queues, database, caching, file storage, and so on. You should include all the core components you need to create the system. </p>
<p>Make sure to communicate with the interviewer during this stage and check to ensure that you aren't missing anything. While they probably won't tell you directly, they will give you a nudge in the right direction if you forgot about some crucial feature.</p>
<h3 id="heading-api-design">API Design</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-114.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>This part is almost cheating because you are using the structure of the interview to your advantage to confirm that you are on the right path. </p>
<p>The interviewer is never going to deliberately lead you down the wrong path, so once you've created your high level design you can start sketching out some rough API endpoints for each component. </p>
<p>For the YouTube example they might look something like this, depending on which features you are building:</p>
<ul>
<li>uploadVideo (userID, video, description, title)</li>
<li>comment (userID, videoID, comment)</li>
<li>viewVideo (videoID)</li>
<li>videoSearch (query)</li>
</ul>
<p>In some cases you might not need to drill down to this level. If the interview question is very high level like "design Youtube", you can probably skip this part. On the other hand if you get a more focused question like "design YouTube's comment system", it would make sense to go more in depth.</p>
<h3 id="heading-create-a-data-schema">Create a Data Schema</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-113.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>At this point you should have a good idea of all the requirements and data needed for the application to work, so now you can plan out how your data is structured. </p>
<p>Depending on what you are building and the requirements, you'll need to weigh the costs and benefits of things like using a relational vs non-relational database. When modeling your data you'll also want to account for things like potential data partitioning and replication.</p>
<h3 id="heading-take-a-detailed-look-at-the-components">Take a Detailed Look at the Components</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-112.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>What happens during this section will mainly depend on the feedback of the interviewer. They will probably pick out a few specific components to focus on and ask why you made certain decisions. </p>
<p>The most important part here isn't necessarily being 100% right. Instead, it's to show that you didn't just blindly make decisions and understand exactly what tradeoffs you were making. </p>
<p>You should be able to propose alternate design decisions that could have been used and explain why you didn't use them.</p>
<h2 id="heading-how-to-design-youtube">How to Design YouTube</h2>
<p>Now that you have a general idea of how a system design interview works and a framework for handling a system design problem, I'm going to show you how to put it all into practice using YouTube as an example.</p>
<h3 id="heading-step-1-define-problem-scope-and-requirements">Step 1 – Define Problem Scope and Requirements</h3>
<p>This will be a high level problem where we implement a few of YouTube's major features without diving too in-depth on any of them. The features to focus on will be:</p>
<ul>
<li>Users can upload videos</li>
<li>Users can view videos</li>
<li>Users can comment on videos</li>
</ul>
<h3 id="heading-step-2-determine-capacity-estimates">Step 2 – Determine Capacity estimates</h3>
<p>The two biggest capacity factors in an app handling large amounts of video like YouTube will be storing all that content and bandwidth requirements to deliver the content to users. In this section you'll learn how to make rough estimates for capacity requirements. </p>
<p>The main focus here is not on being highly accurate, but showing a logical thought process for calculating these numbers based on the information available to you.</p>
<p>In an interview you would be given the data, but in this case I'm using two key pieces of data that YouTube has made public:</p>
<ul>
<li><strong>YouTube creators upload 500 hours of video every minute</strong></li>
<li><strong>YouTube users watch 1 billion hours of video per day</strong></li>
</ul>
<p>You can use these numbers to calculate storage and bandwidth requirements with a few assumptions.</p>
<h4 id="heading-bandwidth-calculation">Bandwidth Calculation</h4>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-92.png" alt="Image" width="600" height="400" loading="lazy">
<em>Daily bandwidth calculation</em></p>
<p>To calculate an estimate for bandwidth, we start with the amount of video watched daily. The key assumption here is how much bandwidth is used per hour watched, as this would depend on the quality of video most users choose to watch. </p>
<p>The 3 Gigabyte estimate is based on a rough percentage of users watching in standard definition and others choosing HD or 4K, which consume much more bandwidth per hour watched.</p>
<p>The math here is fairly simple: multiply 1 billion hours by the average bandwidth of an hour of video, then divide that by 1000 to convert to terabytes, then divide by 1000 again to get to Petabytes. The final bandwidth estimate is <strong>3,000 PB</strong> used daily.</p>
<h4 id="heading-storage-calculation">Storage Calculation</h4>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-91.png" alt="Image" width="600" height="400" loading="lazy">
<em>Step by step calculations for storage</em></p>
<p>Based on a few assumptions we can calculate that YouTube will need to store around <strong>2.16</strong> <strong>Petabytes</strong> of new video every day. Here's how we get that number:</p>
<ul>
<li>Convert 500 hours to 30,000 minutes of video uploaded per minute</li>
<li>Each minute of HD video is roughly 50 Megabytes due to having copies of each video in multiple formats. We multiply that by 30,000 minutes and then divide by 1000 to convert to Gigabytes.</li>
<li>We then take the 1,500GB uploaded per minute and multiply by 60 then 24 to calculate the daily amount of video uploaded. We divide by 1000 again to convert Gigabytes to Terabytes</li>
<li>Our final total is 2,160 Terabytes uploaded daily or 2.16 Petabytes</li>
</ul>
<h3 id="heading-step-3-database-design">Step 3 – Database Design</h3>
<p>For our database we will use a standard relational database like MySQL. The schema will look something like this: </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-93.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>This design is very simple but has the essentials that you'd need for a basic implementation. It would be a good idea to do some research into the differences between relational and non-relational databases so you understand what kind of situations each excel at and when to use them. </p>
<p>For certain apps with different requirements a NoSQL database might make sense. Often large systems will have many different services that use different types of databases depending on their needs.</p>
<h3 id="heading-step-4-high-level-design">Step 4 – High Level Design</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-95.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>That's a pretty complex diagram, so let me break down what's happening:</p>
<ul>
<li><strong>Client</strong> – This could be a user on a mobile app or their computer trying to upload a video, make a comment, or watch a video</li>
<li><strong>CDN</strong> – A content distribution network is used to reduce latency and improve reliability when it comes to delivering static content like videos or images. A CDN works by storing content in data centers all around the world so that the content is closer to users. This results in reduced latency because requests travel a shorter distance. There's also an added benefit of content being stored in multiple locations so even if one location can't serve traffic for some reason, another location can.</li>
<li><strong>Load Balancers</strong> – A load balancer accepts requests and routes them to servers depending on a number of factors. At YouTube's scale, a single server can't handle all the traffic and you want replication to prevent a single point of failure. The load balancer can check the status of servers and verify they can handle traffic or choose another server that can handle the request.</li>
<li><strong>Services</strong> – You can think of this as the app layer of the system. Instead of using a single monolith to handle traffic, we'll use several microservices to handle specific tasks. The second box for each of these services in the diagram represents multiple servers running for each of them to increase reliability. If one replica of the service goes down, there's always another to step in and handle traffic.</li>
<li><strong>Data Stores</strong> – When using microservices it is generally best practice for each microservice to own its own data. If one service needs data from another they can access it through an API.</li>
<li><strong>Video Upload Process</strong> – Handling the video uploads will involve multiple steps, as trying to handle it synchronously with the app server would be fragile and reduce performance. I'll cover this more in depth in the next section</li>
</ul>
<p>I don't want to go too in-depth on these individual components because I could write entire articles on any of them if I wanted to explain them fully. </p>
<p>If you are interested in a more detailed explanation you can check out the system design playlist I linked to above which has videos covering most of these concepts. </p>
<h3 id="heading-step-5-go-over-specific-components-and-details">Step 5 – Go Over Specific Components and Details</h3>
<p>At this stage you have a working design. Now let's look at some of the specific components in detail.</p>
<h4 id="heading-video-upload">Video Upload</h4>
<p>Video content is the lifeblood of YouTube, and it doesn't exist without it. This means that making it quick and easy for users to upload videos is probably the most important feature. </p>
<p>Imagine uploading a multi-gigabyte video to YouTube and then seeing the upload fail after 30 minutes when it's 95% done. To prevent this you'll want to support the ability for resuming uploads if the client's connection is lost temporarily. The uploaded video can then be stored with a distributed file system like HDFS. </p>
<p>Once the upload is complete there's still a lot more to do before the video is ready for users to access. The video needs to be encoded into multiple different quality formats, you need to generate thumbnails, and push copies of the video to the global CDN. </p>
<p>Again, at any stage one of these processes could fail. To prevent this you'll have a task queue to manage this process and retry the processing attempt if it fails at any stage. </p>
<h4 id="heading-database-scaling">Database Scaling</h4>
<p>The database is often the bottleneck of an application. You will probably be tested on whether you understand some of the fundamental concepts around database scaling. This could include caching to handle read requests, sharding, and replication. </p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Hopefully this article has given you a better understanding of what to expect during a system design interview. </p>
<p>This article mainly focused on the structure of the interview itself rather than the concepts you need to understand to answer the questions given during the interview. </p>
<p>Two great resources for beginning to learn about that are:</p>
<p>A great article posted here on Free Code Camp News: <a target="_blank" href="https://www.freecodecamp.org/news/systems-design-for-interviews/">https://www.freecodecamp.org/news/systems-design-for-interviews/</a></p>
<p>The system design primer repo on GitHub: <a target="_blank" href="https://github.com/donnemartin/system-design-primer">https://github.com/donnemartin/system-design-primer</a></p>
<p>Both cover just about every major concept you need to know for your system design interview and should put you in a great position for success.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What to keep in mind when architecting a system ]]>
                </title>
                <description>
                    <![CDATA[ By Ayelet Sachto Architecture may sound like a “scary ” or overwhelming subject, but actually, applying logic and approaching the problem methodologically simplifies the process drastically. When you architect a system, service, or feature, you actua... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/what-to-keep-in-mind-when-architecting-a-system-912ec5c6f79/</link>
                <guid isPermaLink="false">66c3660d8e244e167873863a</guid>
                
                    <category>
                        <![CDATA[ Devops ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software design ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ System Architecture ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 12 Dec 2018 17:54:27 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*GRF6gYIhUy5WBdbsqLWm3A.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Ayelet Sachto</p>
<p>Architecture may sound like a “scary ” or overwhelming subject, but actually, applying logic and approaching the problem methodologically simplifies the process drastically.</p>
<p>When you architect a system, service, or feature, you actually design a <strong>solution</strong> to a problem in a <strong>specific context</strong>. The solution should answer a real need and solve the problem <strong>at hand.</strong></p>
<p>Throughout the text, I’ll be using <strong>solution</strong> in order to emphasize that the <strong>systems, services, and features</strong> we build are part of a bigger <strong>flow</strong>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/i1p8jGfhA263VAS7AsivCRtMxclqCJV36XT5" alt="Image" width="800" height="800" loading="lazy"></p>
<p>When designing a solution think about the entire environment flow you affect.</p>
<ul>
<li>Think about what happens before the data reaches your code</li>
<li>What triggers your feature or service</li>
<li>Who sends it?</li>
<li>Is it something automatic?</li>
<li>Is it a user?</li>
</ul>
<p>This will also help you think about tests and edge cases you want to address, what happens after, who would use it and how.</p>
<h4 id="heading-1understand-the-problem">1.Understand the problem</h4>
<p>Start from understating the problem at hand and understand your boundaries. Don’t optimize for an unknown future, focus on the current situation and most importantly, <strong>don’t make assumptions.</strong> Don’t limit yourself by requirements that are not there.</p>
<blockquote>
<p>Make sure you have all the information you need to understand the problem, don’t be afraid to do research, Google is your friend ;)</p>
</blockquote>
<p><img src="https://cdn-media-1.freecodecamp.org/images/w9FZSfuNF8PsaTT9F8Puxl4mqP1gcDKVTEbI" alt="Image" width="800" height="557" loading="lazy">
_Photo by [Unsplash](https://unsplash.com/@rawpixel?utm_source=medium&amp;utm_medium=referral" rel="noopener" target="_blank" title=""&gt;rawpixel on &lt;a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral" rel="noopener" target="<em>blank" title=")</em></p>
<h4 id="heading-2-understand-your-boundaries-and-set-priorities">2. Understand your boundaries and set priorities</h4>
<p>Solution architecture is always a trade-off between concerns, such as resilience, security, data integrity, throughput, scalability, performance and of course cost.</p>
<blockquote>
<p>Think about value vs friction</p>
</blockquote>
<p>Understand your constraints. What are your <strong>must-haves</strong>. If you have a product team, work with them in order to understand the business need, impact and SLA’s. This will help you understand your considerations and limitations better.</p>
<p>Use <strong>data</strong> to make <strong>priorities</strong>, avoid assumptions when possible and be data-driven.</p>
<ul>
<li>How many users?</li>
<li>Number of requests?</li>
<li>Size of requests?</li>
</ul>
<p>Test your service in order to estimate the resources that are needed.</p>
<blockquote>
<p>Make sure you address the maximum rate you want to support and not only the average (look at percentage vs average).</p>
</blockquote>
<p>Think <strong>about</strong> solving the problem and not just <strong>how</strong> to solve it. First think about the solution and only after that think about the implementation. When you free yourself from the expectation of how the solution <strong>should</strong> look like, you understand that a solution can be provided in many forms. It can be a system, service, feature, process or even documentation.</p>
<h4 id="heading-3-ask-why">3. Ask WHY?</h4>
<p>Challenging people and even yourself can be frustrating sometimes. But asking <strong>why</strong> can help you solve the real problem, understand the mandatory requirements and your boundaries, and can help you avoid mistakes and understand the motivation from the business side.</p>
<ul>
<li>Why is it a real pain?</li>
<li>Why should it be done like this?</li>
<li>Why it works like this today?</li>
</ul>
<blockquote>
<p>Challenge yourself and ask questions. It will help make better decisions and better solutions.</p>
</blockquote>
<p><img src="https://cdn-media-1.freecodecamp.org/images/9T5m8DCeqFgZhYxrTs1XjV5MMWIWK42xILAl" alt="Image" width="800" height="533" loading="lazy">
_Photo by [Unsplash](https://unsplash.com/@emilymorter?utm_source=medium&amp;utm_medium=referral" rel="noopener" target="_blank" title=""&gt;Emily Morter on &lt;a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral" rel="noopener" target="<em>blank" title=")</em></p>
<h4 id="heading-4-your-solution-is-not-in-a-vacuum">4. Your solution is not in a vacuum</h4>
<p>Context is important. A startup of 4 people that needs to provide MVP and is limited by funds will and should solve a problem differently than a team in a big organization that needs to create a sustainable product that will need to be maintained by several teams.</p>
<p>Going back to my first statement, after you understand the problem think about the context.</p>
<ul>
<li>What are the tools you have at your disposal?</li>
<li>Are you part of a big organization?</li>
<li>Are there any limitations such as time or money?</li>
<li>Who will maintain the solution?</li>
</ul>
<p>Think about what is right for <strong>your</strong> situation, define what <em>production ready</em> means to <strong>you</strong>, and whether it should be highly available (HA). Think about the <a target="_blank" href="https://en.wikipedia.org/wiki/Return_on_investment">ROI</a>. Should you address Edge cases?</p>
<ul>
<li>How would you design a solution that will return values from a database?</li>
<li>And what if I told you that it would be used only once a week until the end of the year. Would it change your answer? Would it affect the design?</li>
<li>If you have 1 day to build a solution would it be the same as if you had a month?</li>
</ul>
<p><strong>Think about growth</strong>. For different solutions and different companies, growth means different things. It can be from a <strong>scale</strong> perspective, such as supporting the growth of additional users. It can also be from a <strong>functionality</strong> perspective, where your solution should be <strong>flexible</strong> to enable other developers to add /modify functionality with ease.</p>
<h4 id="heading-5-cost">5. Cost</h4>
<p>As engineers and developers, we sometimes do not stop to think about the cost of our solutions and services. From my experience it is mostly due to lack of awareness and not willingness.</p>
<p>When we are at university, we are “pumped” with performance and complexity concerns, and taught to think about the efficiency of the solution. But when designing a product that will be used, we need to also think about efficiency with regards to cost. You can build an amazing stable and reliable service that provides value, but if its ROI is not high or if your company won’t be able to afford the cost, it will be axed in favor of other alternatives.</p>
<blockquote>
<p>Remember, performance and infrastructure are not free.</p>
</blockquote>
<h4 id="heading-6-production-deployment-is-only-the-beginning">6. Production deployment is only the beginning</h4>
<p>An important concept that sometimes is neglected is <strong>maintenance</strong>. Is our system or service stable and easy to maintain, debug, troubleshoot and fix?</p>
<p>Production deployment is only the beginning of our solution. Make sure it can be easily maintained, make sure it is production ready and can serve real traffic and users. When developing your solution, think about end to end monitoring, focusing on application monitoring vs. utilization, and make sure to add logging and documentation.</p>
<blockquote>
<p>When designing your solution, think about a simple and easy to maintain design, as much as the requirements allow for it of course.</p>
</blockquote>
<p>As developers, we are sometimes drawn to new “flashy” and trendy technologies. Stop to think whether this technology is mature enough. Could it be maintained in production? Could a different stack be more efficient or offer fewer risks?</p>
<h4 id="heading-wrapping-up">Wrapping up</h4>
<p>To recap, if you want to architect the best solution EVER, start from understanding the problem and your limitations, and know the context of the solution you are trying to design for.</p>
<p>Then think about what happens with your solution after it’s up.</p>
<p>Unless you have unlimited funds (which is never the case), think about your solution’s cost and make sure that it maintainable.</p>
<p>If you liked what you read, be sure to ? it below!</p>
<p>Let me know in the comments ❤ if you like more architecture posts and/or would like me to deep dive about each of the points above.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
