How database replication works

Click for: original source

Databases are an essential piece of almost every software product. A database is an organized place to store data. At some point, every company realizes that the amount of data they have increases over time. They cannot afford to lose all the accumulated information. By Dmytro Khmelenko.

Making a regular backup is a good practice (and not only with databases). Generating a backup is a long process and it is not performed every minute. That being said, losing the user’s data gathered since the most recent backup is still a possibility. The general approach to database replication is similar to idea with a backup — to have copies of the data. The difference is in the how. Unlike with a backup, replication is performed on each data modification. This is a permanent process. It is not limited only by that purpose.

While the idea is clear, the implementation brings some challenges. The database roles on each computer in a distributed system cannot be equal. Some databases will accept only write requests and others only read requests. The database performing a write operation is a Leader and the database performing a read-only operation is a Follower.

When there are multiple Leaders in the system, an additional synchronization between the Leaders is necessary. When a user updates data through one Leader, the rest of the Leaders should be notified about the changes. In the era of digital products and constantly growing traffic, data replication becomes a necessity. It not only reduces the risk of disasters and data loss but also improves the performance of the final solution. Good read!

[Read More]

Tags distributed app-development cloud software-architecture