Database Replication and Single Point Of Failure | Pratiksha Bakrola

Sdílet
Vložit
  • čas přidán 5. 07. 2024
  • #SystemDesign #SystemDesignInterview #DatabaseReplication #SPOF #SinglePointOfFailure #SDE #SDEInterviewPrep
    Connect with me on Facebook : / pratikshabakrola
    Subscribe to my channel: / @pratikshabakrola
    Connect with me 1-1: topmate.io/pratikshabakrola
    In this video, I am going to answer these three questions:
    1) What is SPOF- Single point of failure ?
    2) What is Database Replication ?
    3) How to use database replication to avoid SPOF and improve your system availability?
    If you want to learn these things, keep watching.
    In the last video we created this design, and learned what is vertical and horizontal scaling and how to improve your web tier. If you haven’t watched that video, I encourage you to watch that as well.
    Let’s dive in to our question number one.
    So, what Single Point of Failure? When one component of the system fails and as a results, the entire system stops working , that is called SPOF.
    Let’s use this design and to find single point of failure. Load balancer is the first component. If that fails, can your request successfully process? The answer is NO. So load balancer is a SPOF.
    Now, let’s evaluate other components.
    If your web server1 fails, can your request successfully process? The answer is yes. Your request will get routed to web server 2 and then to the database.
    If your web server 2 fails, your request can successfully process using web server 1.
    If your database fails, can your request process successfully ? The answer is no. In this design, your database is also SPOF.
    Now, let’s answer the second question:
    What is database replication? Database Replication is the process of copying data from one database to one or more databases.
    Moving on to question number 3:
    How to use database replication to avoid SPOF and improve system availability?
    As you can see, you only have one database.if your database goes down, your entire system goes down. What we want to do is to have two database. One is Master Database and second is slave database. Only Master database supports write operations like Insert, update and delete commands. Copy of the updated data will be sent to slave database which supports only read operations.
    This instantly improves performance because now we have two database and we can process more queries in parallel. This also failover and redundancy. If one database fails, your system can still function fine using the second database. So, your database is no longer a SOPF. If your master database fails, the slave database will be temporarily promoted to serve as master. If your slave database fails, your read operations will be temporarily directed to master database.
    In any system, the need to read the data is much higher than to write or update the data. So if your user base is growing you can add more slave databases.
    Now let’s say your servers are located in Japan
    And you have two people accessing your website. One person is in Japan where the serves are located and another person is 10K km away in Germany. Will your website load equally fast for both these users? I will give you a moment to put your answer in the comments below. And don’t forger to to hit the notifications bell because in the next video will learn how to improve response time using ache and CDN- Content delivery network.

Komentáře • 9

  • @vaibhavdubey2525
    @vaibhavdubey2525 Před 10 měsíci

    Loved the content.
    Great Work

  • @anonymous_dev9472
    @anonymous_dev9472 Před rokem +1

    If the website is designed to use a master and slave database architecture with all of the databases located in Japan, it is likely that the website will load faster for the user in Japan compared to the user in Germany.
    This is because the physical distance between the user in Germany and the database servers in Japan will introduce additional latency and network delays, which can slow down the website's response time. The user in Japan, on the other hand, will have a faster response time because they are located closer to the database servers.

  • @user-vh8ub2tc9f
    @user-vh8ub2tc9f Před 11 měsíci

    Pratiksha, I have a question, There is one master DB and more than one slave DB to read purpose, it Ok,
    But is there any LB between slave DB?
    Because when too much read request will generate at the pick time how system will decide from which slave DB it will fetch the Data?

  • @shubhamverma1407
    @shubhamverma1407 Před rokem +2

    Pratiksha is this your normal accent ?🤔