Distributed Systems笔记-NFS、AFS、GFS

CMU 95702 关于 NFS、AFS、GFS 的笔记。

NFS(Network File System)


  • Your files are available from any machine.
  • Distribute the files and we will not have to implement new protocols.


  • Defines a virtual C/S file system
  • Stateless
  • Uses RPC over TCP or UDP.

NFS 的实质在于用户间计算机的共享。用户通过 NFS 客户端接入网络,可以访问同一网络中其它计算机系统的硬盘(该计算机为 NFS 服务端)。NFS 客户端可以 mount 远端文件系统的部分或全部到本地,访问这些文件系统就像访问在本地磁盘上的文件系统一样。

NFS 访问数据的速度以接近采用本地磁盘的速度为目标,NFS客户端的性能直接取决于服务端的性能和网络性能。如:

  • 网络的最大吞吐量
  • 服务端硬件性能:网卡,磁盘等
  • 服务端缓存大小,TCP/IP的配置
  • 服务端服务实例的运行个数
  • 客户端请求的网络文件数
  • 客户端的系统性能


NFS architecture


NFS server operations

nfsS1.jpg nfsS2.jpg

-> The directory and file operations are integrated into a single service.

NFS client


AFS(Andrew File System)


  • Scalability


  • Modified from Coulouris
  • Cache
    Whole files are cached in client nodes to reduce client server interactions -> achieve scalability.
    A client cache would typically hold several hundreds of files most recently used on that computer.
    Permanent cache, surviving reboots.
  • Consider UNIX commands and libraries copied to the client.
  • Consider files only used by a single user.
    These last two cases represent the vast majority of cases.
  • Gain: Your files are available from any workstation.
  • Principle: Make the common case fast.

Open file:

  • When the client tries to open a file
    client cache is tried first
    if not there, a server is located and the server is called for the file.
  • The copy is stored on the client side and is opened.
  • Subsequent reads and writes hit the copy on the client.

Close file:

  • When the client closes the file - if the files has changed it is sent back to the server. The client side copy is retained for possible more use.

AFS(Andrew File System) 文件系统主要用于管理分部在不同网络节点上的文件。AFS 采用安全认证和灵活的访问控制提供一种分布式的文件和授权服务,该服务可以扩展到多个客户端。


AFS architecture


Implementation of file system calls in AFS


File name space seen by clients of AFS

System call interception in AFS

The main components of the Vice service interface

CMU’s Coda is an enhanced descendant of AFS
Very briefly, two important features are:
Disconnected operation for mobile computing.
Continued operation during partial network failures in server network.
During normal operation, a user reads and writes to the file system normally, while the client fetches, or “hoards”, all of the data the user has
listed as important in the event of network disconnection.
If the network connection is lost, the Coda client’s local cache serves data from this cache and logs all updates.
Upon network reconnection, the client moves to reintegration state; it sends logged updates to the servers. From Wikipedia

GFS(Google File System)


  • Scalability


  • Reliably with component failures.
  • Massively large files
    Solve problems that Google needs solved – not a massive number of files but massively large files are common. Write once, append, read many times.
  • Streaming and no cache
    Access is dominated by long sequential streaming reads and sequential appends. No need for caching on the client.
  • Throughput more important than latency.
  • Each file is mapped to a set of fixed size chunks(64Mb/chunk).
  • 3 replicas
    Each chunk is replicated on three different chunk servers.
  • Master and chunk servers
    Each cluster has a single master and multiple (usually hundreds) of chunk servers.
    The master knows the locations of chunk replicas.
    The chunk servers know what replicas they have and are polled by the master on startup.

Think of very large files each holding a very large number of HTML documents scanned from the web. These need read and analyzed.
This is not your everyday use of a distributed file system (NFS and AFS). Not POSIX.

Google physical infrastructure






Suppose a client wants to perform a sequential read, processing a very large file from a particular byte offset.

  • The client can compute the chunk index from the byte offset.
  • Client calls master with file name and chunk index.
  • Master returns chunk identifier and the locations of replicas.
  • Client makes call on a chunk server for the chunk and it is processed sequentially with no caching. It may ask for and receive several chunks.


Suppose a client wants to perform sequential writes to the end of a file.

  • The client can compute the chunk index from the byte offset. This is the chunk holding End Of File.
  • Client calls master with file name and chunk index.
  • Master returns chunk identifier and the locations of replicas. One is designated as the primary.
  • The client sends all data to all replicas.The primary coordinates with replicas to update files
    consistently across replicas.
徐阿衡 wechat