...

Text file src/github.com/docker/distribution/docs/architecture.md

Documentation: github.com/docker/distribution/docs

     1---
     2published: false
     3---
     4
     5# Architecture
     6
     7## Design
     8**TODO(stevvooe):** Discuss the architecture of the registry, internally and externally, in a few different deployment scenarios.
     9
    10### Eventual Consistency
    11
    12> **NOTE:** This section belongs somewhere, perhaps in a design document. We
    13> are leaving this here so the information is not lost.
    14
    15Running the registry on eventually consistent backends has been part of the
    16design from the beginning. This section covers some of the approaches to
    17dealing with this reality.
    18
    19There are a few classes of issues that we need to worry about when
    20implementing something on top of the storage drivers:
    21
    221. Read-After-Write consistency (see this [article on
    23   s3](http://shlomoswidler.com/2009/12/read-after-write-consistency-in-amazon.html)).
    242. [Write-Write Conflicts](http://en.wikipedia.org/wiki/Write%E2%80%93write_conflict).
    25
    26In reality, the registry must worry about these kinds of errors when doing the
    27following:
    28
    291. Accepting data into a temporary upload file may not have latest data block
    30   yet (read-after-write).
    312. Moving uploaded data into its blob location (write-write race).
    323. Modifying the "current" manifest for given tag (write-write race).
    334. A whole slew of operations around deletes (read-after-write, delete-write
    34   races, garbage collection, etc.).
    35
    36The backend path layout employs a few techniques to avoid these problems:
    37
    381. Large writes are done to private upload directories. This alleviates most
    39   of the corruption potential under multiple writers by avoiding multiple
    40   writers.
    412. Constraints in storage driver implementations, such as support for writing
    42   after the end of a file to extend it.
    433. Digest verification to avoid data corruption.
    444. Manifest files are stored by digest and cannot change.
    455. All other non-content files (links, hashes, etc.) are written as an atomic
    46   unit. Anything that requires additions and deletions is broken out into
    47   separate "files". Last writer still wins.
    48
    49Unfortunately, one must play this game when trying to build something like
    50this on top of eventually consistent storage systems. If we run into serious
    51problems, we can wrap the storagedrivers in a shared consistency layer but
    52that would increase complexity and hinder registry cluster performance.

View as plain text