Introduction to FastCFS Synchronous Replication Mechanism

    The previous article introduced the way that FastCFS adopts data grouping. There is a Master/Slave relationship between several nodes of a data group (such as three nodes or three copies); FastCFS adopts a strong data consistency model, through the Master/Slave structure. Synchronous replication mechanism to ensure data consistency, this article will briefly introduce the principle and key points of this mechanism.


    Compared with stand-alone systems, distributed systems have great uncertainty in network communication, and it is very challenging to achieve strong data consistency. The mainstream practice of distributed systems in the industry is to use the BASE theory to deliberately avoid the problem of strong data consistency. The BASE theory is the abbreviation of the three phrases Basicly Available (basically available), Soft State (soft state or intermediate state) and Eventually Consistent (eventually consistent). The BASE theory is more partial to engineering practice. See the text and know the meaning. Friends who need to know more about it will make up their own minds.


    Using the Master/Slave structure, the logic to ensure strong data consistency is very simple. The update operation of the client can only be handled by the master, and then the master calls the slave synchronously to forward the request. In FastCFS, the master can request multiple slaves concurrently, so the response time of the client and the number of slaves (number of copies) are not linear. The master will only initiate a synchronous call to the online (ACTIVE) slave. Then the slave is offline (OFFLINE) due to restarting the service or abnormal network communication. How does FastCFS handle it? The slave in the OFFLINE state will enter the data recovery (append data) phase, and only after catching up with the latest data of the master can it switch to the ACTIVE state. To ensure smooth switching, an intermediate state of ONLINE is introduced.


    Some friends have said that the above synchronous replication method is very simple and straightforward, and it is not very advanced. Well, simple is often the most effective. The challenge is not in the complexity of the solution, but in the engineering implementation. On the premise of ensuring data consistency, the two key points of the data synchronous replication solution are maintaining accurate cluster state and smooth slave state switching.


    FastCFS introduces the mechanism of leader/follower to maintain accurate cluster status. The leader is elected, and the follower establishes a connection with the leader and reports its own status (disk space, data version number, etc.) every second. When the cluster state changes, such as master switch, slave state change, etc., the leader will immediately push the change message to all followers. The same function can be achieved with zookeeper or etcd, so why make your own wheels? There are two reasons: first, independent and controllable, reducing dependence; second, simple and efficient, to avoid bloat.


    On the premise of ensuring strong data consistency, distributed systems must also achieve high availability and high performance, which is a great challenge. In order to do this, there is one more crucial place, which will be revealed to you in the next article.

This article is shared from the WeChat public account - FastDFS Sharing and Exchange (fastdfs100).
If there is any infringement, please contact [email protected] to delete it.
This article participates in the " OSC Yuanchuang Project ", you are welcome to join and share with us.

{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324128059&siteId=291194637