FastDFS picture download problem, ask for advice

recently, I was looking at the Taobao Mall project and uploaded pictures with fastDFS. When uploading, tracker found a free storage to upload pictures and returned the upload path. The question is, when downloading, why can"t you download directly with the path? instead, you need to continue to visit tracker to see which storage is free. The problem is that the uploaded storage is fixed, but there is a picture on that group of storage, and the ip address of a group of storage is the same. The information returned by that tracker can only be the IP address and image path of that group of storage with pictures. The question is that I got all these when I uploaded them, so why should I get

again when downloading?
Apr.23,2021

first let's talk about uploading:
there are multiple storage in a group, and the ip of each storage is different. The storage of the same group will share Synchronize data with each other. When uploading, tracker selects a storage in a group to upload, and records the group (G1) and storage directory (M00) of the group in which the file belongs in the returned fileID string. Store the secondary directories in the directory (256 in total), stored timestamps, file offset information, etc.

then download:
FastDFS is for massive small file storage scenarios, where you write and read multiple times at a time, so you need to do load balancing for reading. Since multiple storage in a group are Synchronize to each other, you have to visit one of these storage when you get the storage belonging to a group. But because Synchronize has a delay, you save it and read it in a short time (this scenario is very common). This file may only be Synchronize to part of the storage, as a client. How do you know which storage has? The client cannot know, and tracker knows that it compares the last time of each storage's Synchronize log with the timestamp in fileID, judges whether the file has been sent to a certain storage by Synchronize according to some logic, and then randomly selects a storage that already has the file for you to download, thus realizing the load balance of the storage in the group

.

accompanying pit
it is said that when downloading, tracker picks the storage according to the timestamp in fileID and the Synchronize time point of each storage. Assuming that the time between storage is not Synchronize, it may appear that tracker determines that the Synchronize time point of storage has exceeded the time stamp of fileID long enough, then let it be downloaded for you, but in fact, it is possible that the storage has not come over Synchronize this file, resulting in download failure. Therefore, the time between storage and Synchronize in the same group is necessary


recently, I saw that multiple storage servers under one group of fastdfs, are Synchronize with each other. The path returned when uploading is only the address of the source storage server, which does not mean that you need to download from this address, and you can also download it from other storage server nodes under this group. Therefore, you need the tracker server to reacquire it and decide which storage node to download from.

Menu