Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the FastDFS tracker leader mechanism?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

What is the FastDFS tracker leader mechanism, I believe that many inexperienced people do not know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

FastDFS tracker server does not save the file index, only the cluster topology information. According to the original design, multiple tracker server in FastDFS are completely equivalent, and there is no master-slave relationship. FastDFS v3.0 began to support file merge storage, while trunk space management is also performed by a storage server of a group, a role we call trunk server. Trunk server is specified by tracker server, and if multiple tracker server can specify trunk server, confusion and conflicts are likely to occur. So v3.0 begins to support tracker leader and follower mechanisms, and major cluster-related issues are decided by leader, such as trunk server allocated by tracker leader.

Tracker server does not require the number of nodes, and considering that the popular leader election algorithm Raft algorithm is more complex, so it uses a simple algorithm based on rules to select the most reliable leader as far as possible, we can understand it as seniority algorithm. The election of tracker leader consists of two actions: pre-election and confirmation, in which the pre-selected leader notifies each tracker server of its identity. Here are the preselection rules and steps:

1. If a tracker server is already a leader, then retain its qualification, otherwise go to the next step

two。 Select the tracker server with the longest running time, if all are the same to the next step

3. Select the tracker server with the shortest restart interval. If all are the same, go to the next step.

4. Select the tracker server with the highest IP address. If all are the same, go to the next step.

5. Select the tracker server with the largest port.

Note: the running time and restart time interval are rounded and passivated according to 300 seconds to eliminate the small time difference of batch restart of multiple fdfs_trackerd instances, so that the time after passivation is consistent.

After the election of tracker leader, follower periodically (currently per second) checks the survival of leader through ping. If the ping leader fails three times in a row, the leader is re-elected.

For simplicity, take two tracker server as examples to illustrate the famous brain fissure phenomenon in the distributed system. If two tracker server cannot communicate with each other for some reason (such as a router or switch failure), a brain fissure occurs when both tracker server consider themselves to be leader. If the network channel between the two tracker server cannot be restored, the brain fissure will continue.

How does FastDFS solve the possible tracker leader brain fissure problem? The solution is simple: introduce storage server as the observer and coordinator. Storage server reports its status (including disk free space, file operation statistics, and so on) to all tracker server periodically, tracker leader tells storage server its identity in the returned response, and then storage server knows if there are multiple exceptions in tracker leader. If more than one leader,storage server appears, the tracker server will be notified to re-elect the leader.

After reading the above, have you mastered what the FastDFS tracker leader mechanism is? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report