Sunday, March 11, 2007

LBFS: A low bandwidth file system

LBFS is a client server based network file system that is optimized for low bandwidth links. Main novelty is identifying duplicates in data (this technique came to be known as "content-defined chunking (CDC) after this paper was published) and not transmitting these duplicates between the client and the server.

The full LBFS uses a lot of other existing bandwidth optimization techniques and could potentially benefit from lot of techniques for bandwidth reduction especially over wide-area networks:
  • Aggressive client caching, write behind cache
  • Lease based server callbacks to tell clients to tell clients when files have been changed on the server
  • Batching file system operations as in NFSv4
  • Pipelining of RPC calls (would work even with NFSv3).
  • CODA disconnected operations
  • Operation-based updates ("Operation based update propagation in a mobile file system, Usenix 1999)
Identifying duplicates (Content-defined chunking):

LBFS identifies duplicates within files and across files. Also, it assumes that modifications to a file leave most of its contents unchanged, it optimizes that commonality as well, i.e., identifying duplicates across multiple versions of a file.

The technique of splitting a file into smaller units (chunks) for purposes of comparing for identifying duplicates is called chunking. A simple chunking algorithm is to chunk a given file into chunks of equal sizes. This technique however may do a poor job of identifying duplicates. Some advanced techniques compute "overlapping chunks", i.e., chunks that are not disjoint to not catch any possible duplicates. However, recording these chunks by their offset within the file doesn't work as it requires re-chunking when the file is modified and offsets change. In short following are the goals of a chunking algorithm:
  1. In a given static state of files, should be able to identify most number of duplicates
  2. For dynamic files, changes to a file, e.g., inserting and deleting some data in the middle should not affect existing chunks - so only minimum number of chunks should need to be recalculated.
  3. Minimum overhead in space and time.
The second goal cannot be accomplished by offset based chunking. Rather, as data is inserted say into the middle of a file, chunks that don't get changed should shift in the file and not need to be recalculated. This can be achieved by a chunking scheme based on the contents of a file. LBFS defines chunk limits, or "breakpoints", based on the actual contents of the file at the breakpoint. So as the content and hence the breakpoint shifts, so does the chunk. Breakpoints are selected using Rabin fingerprints on overlapping 48-byte regions. A Rabin fingerprint is the polynomial representation of the data module a pre-determined irreducible polynomial. When the low-order 13 bits of a region's fingerprint match a magic value, the region is identified as a breakpoint. Given the randomness of SHA-1, matching 13-bits generates a breakpoint every 8KB on an average over random data. However, pathological cases are possible (e.g., all
zeros), so LBFS restricts chunk size between the interval [2KB, 64KB].

Architecture:

The key component of LBFS on both client and server side is a chunk database which maps SHA-1 hashes of chunks to triples. This mapping must be updated whenever a file is modified.

LBFS is implemented as a modification to the NFSv3 protocol. At the client side, an LBFS driver uses SunRPC calls to communicate with the server and uses a local chunk database. At the server side, LBFS
driver is implemented as a stackable file system: it pretends to be an NFS server to the remote client, but locally acts as an NFS client to a local NFS server. By working on top of an NFS server, it doesn't
have to reinvent the wheel for a lot of basic operations. E.g., the LBFS server implements atomic commit (described below) using 4 new rpc calls added to the NFS server. It also maintains a chunk database.

File consistency:

LBFS uses a close-to-open consistency model like AFS. In addition, it doesn't clear cached contents of a file from the client when the file is closed. This is useful for the case when the file is reopened in the near future. File's contents are written atomically to the server upon close to avoid a mishmash of updates from multiple clients. For this purpose, LBFS adds a few rpcs to NFS. These RPC calls are implemented in a way such that the chances of identifying duplicates are not reduced.

Closest prior arts:

"A protocol independent technique for eliminating redundant network traffic":
This paper implements two chunk indexes on the client side and server side at the network protocol layer behaving as cooperative caches, so would work for most kind of traffic. But its too generic and doesn't solve the problems you'd need to solve for a file system, e.g., data at server could have changed, or data at client could have changed as the result of a write, etc.

Rsync
Tries basic overlapping-chunk comparison for similar looking files.

Interesting design points:
  • LBFS is built on top of NFS as an extension to NFSv3. In this way, it bets a bunch of implementation of an network file system for free, including access control. NFS also seems easily extensible (of course requiring source code changes) by adding new RPCs as needed.
  • LBFS server is essentially like a stackable file system or filter driver, it pretends to be an NFS server to the LBFS client but locally behaves like a client to the actual NFS server. In this way, it can work on top of any file system for which an NFS server has been written. However, since LBFS server runs in user space, it could have as well been implemented using system calls - that way also it would work for any file system. However, there are key reasons for using an NFS interface to the server than system calls:
    • With system calls, renaming a file changes the identity of the file (its name), whereas with NFS, the file handle doesn't change, so less changes to chunk database.
    • Grossly simplifies the implementation since the LBFS protocol is NFS-based.
    • LBFS gets access control for free by reusing NFS server's access control mechanism.
  • LBFS doesn't bother too much about keeping the chunk database consistent with file contents as its difficult to ensure this during crashes and concurrent updates. Instead, it recomputes the hash every time it gets a hit in the chunk database. This was an interesting design decision since it reduced the complexity considerably in exchange for a slight cost to performance.
Discussion:
  • Although LBFS CDC has signifcant overlap with techniques for de-duplicating data, it is applied to a very different scenario. Data de-duplication is often feasible only for static data as for non-static data, removing duplicates often costs in terms of seek time when doing sequential IO. With LBFS, data is non de-duplicated at server side, its only the client-server communication that enable de-duplication. If client's chunk database may be accommodated in its memory, there won't be such a performance hit.
  • In LBFS, modification to a file does not invalidate existing chunks which are not affected by the write. However, LBFS still incurs an extra cost with each update for updating the chunk database to update the mapping from SHA-1 hash to .

Referrences:

Athicha Muthitacharoen, Benjie Chen, and David Mazières. A Low-bandwidth Network File System. Proc. 18th Symposium on Operating Systems Principles. Banff, Canada. October, 2001.

No comments: