A Distributed File System: By, Prof Ankita Mandore
A Distributed File System: By, Prof Ankita Mandore
The third method is to carry out file replication using groups. In this method,
a Write system call is sent to all the servers (S1, S2, S3), and multiple replicas
are created when the original is made.
In lazy replication, only one server is addressed-not the entire group-and it
happens in the background when the server is free; while in the group
mechanism, all the copies are made at the same time.
Each of these three methods has its own advantages and disadvantages but all
the methods provide transparency.
Update Protocols
Consider a scenario shown in Figure, where a client is connected to three file
servers each storing a replica of file f. Suppose the client appends the file in
its memory. Now the file updates have to be sent to all servers so that the
replicas are consistent. To do this the client sends a write f message to all
servers: S1, S2, and S3 which have replica of file f. If the client crashes after
sending the first two writes to S₁ and S2, all the replicas are not consistent.
Hence the read operations on these servers now will give different values.
Primary copy algorithm
In this algorithm, one server is designated as primary and all other
servers are termed as secondary, as depicted in Figure 9-18(b).
When a replicated file is to be updated, the changes are sent only
to the primary server (1). It makes the changes locally and writes
to stable storage. This avoids problems in case of primary crash
and sends an update command to all the secondary to make the
corresponding changes. Read operations can now be done either
from the primary or the secondary servers, thus, balancing load.
There is a possibility that the primary server crashes before it has
propagated the changes to all the secondary. Hence, the updates
are always written to a stable storage. When a server reboots,
checks are made to see whether any updates were in progress at
the time of crash. If so, then the updates are carried out, and
later, all secondary are updated. The only disadvantage is that no
updates are performed if the primary is down.
Voting algorithm
A voting algorithm is proposed to overcome the problems
with a single primary, which requires that the client
should request permission from more than one server
before performing a Read or Write operation on files and
their replicas. In the simple majority voting algorithm,
only votes from most current replicas are valid. As shown
in Figure 9-19, consider a client and a five server
distributed system. Each server, S1, S2, S3, S4, and S5,
stores a copy of file fifth a version number, f2 (S1, S2,
S3) or f3 (S4, S5). Now the client wants to write in file
f₂. The following steps are carried out: 1. Client sends a
message to ask the version number from a majority of
the servers (S1, S2, S3). 2. Those servers send a reply
message specifying the current file version-f₂. Client
understands that the files are updated in majority of the
servers. 3. Now client can update the file stored on each
server: S1, S2, S3, S4, and S5. Such voting is carried out
for both Read and Write operations by the client.
Two Phase Commit Protocol (Distributed
Transaction Management)