[00:00] Picture this, you're on call and suddenly, BAM, your system decides to take a unplanned vacation. We've all been there. System outages are just part of our software engineering journey. And trust me, nobody wants to explain to their boss why the e-commerce site crashed on Black Friday because of a single server failure. [00:19] Today, we're diving into how to build fault-tolerant systems that keep running even when things go wrong. We'll explore several key strategies and see how they work together to build robust systems. At its core, fault-tolerant means our system continues to function even when some components fail. [00:37] We plan for failure by anticipating breakdowns and putting recovery measures in place before things go sideways. Let's begin with replication, redundancy, and failover, which are closely related yet serve distinct roles. [00:51] Replication is all about making copies of critical data or components. Imagine our payment service relies on a single database. If that database crashes during peak traffic, transactions grind to a halt. [01:04] By replicating the database, we create multiple synchronized copies. For example Cassandra replicates data across multiple nodes in a cluster Each piece of data is stored on several nodes so if one node becomes unavailable the data can still be accessed from other nodes in the cluster Redundancy means having additional components or systems that can take over in case of a failure [01:28] This can be implemented in different ways. In an active-active configuration, multiple instances of the same service run simultaneously, with a load balancer distributing traffic between them. [01:40] In an active-passive setup, a backup instance stands ready but only takes over when the primary instance fails. Storage systems like RAID also demonstrate redundancy. RAID 0 splits data across disks for performance but offers no redundancy, while RAID 1 mirrors [01:58] the same data across multiple disks. This is redundancy. Failover ties replication and redundancy together by switching to a standby system when the primary run fails. In a typical setup, system monitoring constantly watches the health of primary servers. [02:14] If a failure is detected, the system can redirect traffic to standby servers. The key is having both the monitoring to detect failures and the mechanism to redirect traffic to the backup systems. [02:27] Moving on to load balancing. When running a popular streaming service during a season finale millions of users might try to tune in at once If all the traffic hit one server it would be like clocking a single highway during rush hour Load balancing [02:43] distributes incoming traffic across multiple servers. Tools like Nginx and HAProxy manage this distribution, using algorithms that range from simple round-robin to more advanced methods [02:55] that account for server load and health. Even with these strategies in place, there are times when complete failure is inevitable or recovery takes longer than expected. This is where graceful degradation comes in. [03:09] Instead of allowing the entire system to collapse, graceful degradation ensures that our most critical features keep functioning, while non-essential parts may be temporarily disabled. During heavy load on social media site, [03:22] We might throttle real-time comments updates to preserve the core feed and posting functionality. Or we might implement circuit breakers that temporarily stop requests to failing services [03:34] to prevent cascading failures across the system. Finally, monitoring and alerting are important. All these strategies are only effective when we know when something is going wrong. [03:46] Continuous monitoring tools like Prometheus track metrics such as CPU usage error rates and latency while Grafana visualizes these metrics in real dashboards When issues arise tools like PagerDuty send immediate alerts [04:00] so we can address problems before they escalate. Now let's tie these concepts together with an example in AWS. In AWS, we can deploy our application across multiple availability zones, [04:12] physically separated data centers within a region. By replicating our database across these zones, using synchronous replication. We ensure data consistency even if one zone encounters an issue. [04:25] Redundancy is achieved by deploying our application in each zone, and failover mechanisms automatically redirect traffic if one zone goes down. Building truly fault-tolerant systems is an ongoing process. [04:37] It involves implementing these strategies and continually refining them to meet our specific needs. Although these strategies add complexity, cost, and extra development effort. [04:49] They are essential investments in reliability and user satisfaction. If you like our videos, you may like our system design newsletter as well. It covers topics and trends in large-scale system design, [05:02] trusted by 1 million readers.