Course contents 06 / 35

06 / 35 · Files and Tables

Distributed files and object storage

Follow file blocks through HDFS, address byte ranges through S3 and separate the lifetime of data from the worker cluster.

The shop’s analytics cluster can finish a report and shut down. The next cluster still needs the same sales file. Storage must keep the data independently of the reporting processes. We also need to know which service resolves the name and which service transfers the bytes.

A file name resolves to blocks#

HDFS gives clients a file-system namespace with files and directories. The NameNode maintains the namespace and the mapping from file blocks to DataNodes. DataNodes store and serve the block bytes. A client obtains locations from the metadata service and reads from DataNodes directly. The bytes do not pass through the NameNode. The original Google File System used a related split between master metadata and direct chunk-server access. (Hadoop 3.4.2, HDFS Architecture, Ghemawat et al., §2.3)

Take a file of 300 MiB with a configured 128 MiB block size. In a simple full-block layout the blocks contain 128, 128 and 44 MiB. With three complete replicas of every block, the storage holds 3⋅300=9003\cdot300=900 MiB of file payload. A full read needs one readable copy of each block and transfers 300 MiB of payload. The extra copies let a reader choose another location if one copy is unavailable. Real placement depends on the topology and the replication policy.

An HDFS-aware scheduler can put a task near one replica to save network traffic. Local placement is a scheduling option, and remote clients can read too. The typical access pattern is streaming through large files, with an append or truncate operation available under the HDFS model. It is a different contract from arbitrary in-place updates at a byte offset. (Hadoop 3.4.2, HDFS Architecture)

An object key resolves through an API#

In a general purpose S3 bucket, a key addresses an object. The key can contain slash characters that tools display as a folder hierarchy. The client uses the storage API and does not request the physical locations of the object’s internal copies. It can request a byte range of a particular object with GET. That makes reading a file footer or selected data chunks possible without downloading the full object. Amazon S3 accepts one byte range per GetObject request. (Amazon S3 User Guide and API Reference)

Figure

Two paths from a name to bytes

Two paths from a name to bytesIn HDFS the client obtains block locations and reads from DataNodes. In S3 the key and range request returns bytes through the API.HDFSFile pathNameNodeDataNodesS3Object keyGetObjectByte range
In HDFS the client obtains block locations and reads from DataNodes. In S3 the key and range request returns bytes through the API.

Suppose the same 300 MiB object contains two required byte ranges of 64 and 32 MiB, with no overlap. Two range requests transfer 96 MiB of payload. If both share a link capped at 80 MiB/s, the data transfer alone takes at least 96/80=1.296/80=1.2 seconds, against 300/80=3.75300/80=3.75 seconds for the full object. Request overhead, contention and decoding can lengthen either time. A file format has to tell the reader which ranges are useful. The object service sees keys and bytes.

For Amazon S3, a successful write of an object is visible to a later read of that key. That guarantee applies to the object operation. If a writer updates two keys in succession, a reader between those operations can see one new object and one old object. Strong reads for each key do not create an atomic update across both keys. A later note will give a group of files one published version. (Amazon S3 User Guide, Data consistency model)

Let storage and compute scale separately#

Workers can start, read immutable inputs, write outputs and stop. Independent storage lets those workers be replaced without recopying every input onto the new machines first. A cluster that shares physical machines with storage can exploit locality. A separate compute fleet can scale independently, while remote reads consume network bandwidth and may add request costs. The persistence of the file is a property of the storage system and its retention settings, not of any worker staying alive.

Next#

The storage API can return 96 MiB instead of 300 MiB only if the reader knows what to request. File formats: Avro and Parquet explain how the bytes inside a file determine that choice.

References#

  1. Apache Hadoop. HDFS Architecture, 3.4.2. Metadata, block placement, replication and streaming access.
  2. Sanjay Ghemawat, Howard Gobioff and Shun-Tak Leung. The Google File System. SOSP, 2003, §2.3. Describes separating master metadata from direct chunk access.
  3. Amazon Web Services. Amazon S3 User Guide and GetObject. Object keys, per-key consistency and range requests.