Skip to content

Store large objects separately from metadata

11 min reading

Design upload, object identity, metadata and retrieval responsibilities

Page details

System Design · Store and find data

11 min reading · 24 min with practice

Sources

Published · Last edited:

Prerequisite: Compose a distributed key-value store. For basics, use the independent System Design foundations.

More
20px

Hypothetical scenario. Northwind adds product images. One upload reaches object storage, but the metadata update does not finish. Dev can point to the uploaded bytes; Priya cannot find a catalogue record that safely tells a visitor to use them.

Dev: “The image exists in storage.”

Maya: “What makes this particular version ready to appear on the product page?”

Separate storing bytes from publishing the reference that makes them usable. Trace intent, upload, verification, publication and retrieval without assuming that two stores share one transaction. Preserve the earlier distinction between small catalogue responses and the larger objects they identify.

Which record tells the reader these bytes are ready?

An object store manages byte sequences identified by object keys within its namespace. Metadata records describe which object belongs to a product, which version is current and whether that object is ready for readers. The catalogue can return a small object reference without transporting the object through every database query and application response.

Amazon S3’s user guide provides a concrete object-storage model. Using S3 does not eliminate the application’s product relationship, publication state or access rules. Those remain explicit responsibilities even where the storage service supplies useful object metadata and versioning capabilities.

The boundary is not absolute: databases can store large values, and object stores can retain metadata. Choose the arrangement for the access and lifecycle needs. Here, separate product queries, image transfer and publication state make the responsibilities easier to explain and operate.

Create an intent before claiming readiness

Begin with a metadata intent identifying the product, proposed image version and permitted uploader. It is not yet a public ready image. Allocate an object identity that will not overwrite an unrelated product’s bytes. The client or upload service then transfers the object through a path authorized for that intent.

Do not mark the image ready merely because a client reports that it finished sending. The publication path needs evidence that the expected object exists and satisfies the chosen checks. Depending on the feature, checks may include expected size, integrity, media type and necessary content processing. State the actual acceptance rule rather than claiming that an object-store response proves every application property.

Object bytes and publication state have separate ownersAn upload intent in metadata authorizes an object transfer. After verification, metadata publishes the ready object version. Catalogue reads return only a published reference; the object bytes travel from object storage or the edge to the visitor.Upload intentNot yet readyObject transferVerify bytesPublish versionMetadata decisionCatalogue returns ready referenceBytes served separately
Transfer completion and product publication are different events.

Treat publication and collection as competing transitions

Hypothetical scenario. Product Q7 points to image manifest M12, which names immutable object O12 and its checksum. An upload intent begins pending; verification establishes the expected bytes; a conditional metadata update makes M12 current. Uploading O12 alone never makes it the product's selected image.

Treat publication and collection as competing transitions — selected design evidence
Metadata identityFieldsProtected transition
Upload intent U12Q7, object O12, pending, expiryPending to verified or expired
Manifest M12O12, checksum, source revisionImmutable content reference
Current pointer Q7manifest M12, expected predecessorConditional publish
Collection must exclude any object still eligible for publication or referenced by a retained manifest.Collection must exclude any object still eligible for publication or referenced by a retained manifest. Pending intent to Verified object: bytes + checksum match; Verified object to Published pointer: conditional metadata update.Pending intentVerified objectPublished pointerbytes + checksum matchconditional metadata update
Collection must exclude any object still eligible for publication or referenced by a retained manifest. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

An orphan collector and a publisher can race. A collector cannot safely delete an apparently unreferenced object if a valid pending intent may still publish it. Protect publication eligibility and collection through a lifecycle rule: expire or claim the intent under the same authority that admits publication, then delete only after its retained-reference checks pass. The exact conditional operation must be implementable in the selected metadata store.

Replication stores full copies; erasure coding distributes data and parity fragments. A toy six-data-plus-three-parity stripe has nine fragments and a 9 ÷ 6 = 1.5 raw size multiplier at equal fragment size, before metadata and padding. This arithmetic says nothing about a particular provider's durability or failure independence. Choose protection with repair traffic, fragment placement and degraded reads in view.

Publish a specific verified version

After verification, update the product’s ready-image reference under the application’s chosen concurrency rule. A delayed upload for an older edit must not replace a newer accepted image. Recording the expected product version or upload generation gives the publication decision something concrete to compare; the later transaction chapter develops local enforcement.

Use an immutable object identity for a published version where the lifecycle supports it. A visitor requesting that identity should receive the bytes associated with that version, rather than whichever upload most recently reused a mutable name. The metadata pointer can change to a new version without making the old identity ambiguous.

A stable public image URL and a version-specific object identity are different choices. A stable URL can still be implemented, but its cache and replacement semantics need an explicit contract. The edge-caching lesson already showed why changing authoritative state does not automatically update every reused response.

Derive bytes and metadata separately

Hypothetical worked example. Choose one hundred product images, each with a selected payload of 2,000,000 bytes. Total object payload is 100 × 2,000,000 = 200,000,000 bytes. Choose five hundred bytes for each associated metadata record. Metadata payload is 100 × 500 = 50,000 bytes before database structure, indexes and history.

The selected object-to-metadata ratio is 2,000,000 ÷ 500 = 4,000. That ratio explains why making catalogue selection transport the object bytes would change the work dramatically. It is not a claim that every real image or metadata record has either selected size.

For an illustrative upload burst of ten images per second, object payload demand is 10 × 2,000,000 = 20,000,000 bytes per second. New metadata payload at one record per image is 10 × 500 = 5,000 bytes per second. Requests, protocol overhead, integrity checks, replication and processing outputs are excluded from both estimates.

The earlier 2,000-byte catalogue response assumption now applies only to its declared representation, potentially including an image reference. It does not include an image fetched separately. Record and measure those two transfers independently rather than quietly counting image bytes inside the old catalogue budget.

Name the states between the stores

An intent can exist without completed bytes. Bytes can exist while verification or publication is pending. A ready reference can exist while an object becomes unavailable. These states are possible precisely because publication crosses independently operated boundaries. Treat them as part of the workflow, not anomalies a two-store diagram somehow prevents.

For incomplete intents, define expiration and a recovery decision. For uploaded but unpublished objects, define whether a retry can resume publication or whether cleanup may eventually remove them. For a broken ready reference, stop claiming a usable image and retain evidence needed to repair or replace it.

Cleanup must not race with legitimate work. Before deleting an apparently orphaned object, account for pending intents, publication attempts and the selected retention policy. A recently unreferenced object may still be needed by in-flight readers or an allowed rollback. An arbitrary timer does not establish that deletion is safe.

In the wild: object guarantees have a scope

S3 documents its object model and consistency behavior. Those guarantees concern operations within the service’s defined scope. They do not make a separate product database update atomic with an object upload. Northwind’s publication workflow still needs to connect the two outcomes and handle a failure between them.

Likewise, a successful object retrieval does not establish that the product is currently eligible to display it. Public catalogue images are the selected scope here. A future private attachment feature would require authorization at the relevant retrieval boundary rather than assuming that knowledge of an object address is sufficient permission.

When upload succeeds and publication does not

Hypothetical failure scenario. The object store retains the image, but the publication request times out before the catalogue records the ready reference. A second attempt uploads another copy and marks the first abandoned. Repeated attempts consume storage while the reader still sees no image.

Keep the original intent and proposed version identity across retries. Inspect whether the first object is complete and whether publication already succeeded before creating another logical upload. The later idempotency lesson develops that retry contract; here the state model makes the uncertainty visible enough to recover.

Choose the separation when the lifecycle benefits

Separate objects from metadata when byte transfer, serving, retention and processing have materially different needs from record selection. Keep simpler storage where objects are small and the extra coordination adds little value. The decision should follow the feature’s lifecycle and operating constraints, not a rule that all files must use one storage pattern.

Northwind now has ready product records that point to specific published image versions. The next lesson asks how users find those records when they do not know an identifier. Search will create another derived representation, and it will inherit the same requirement to distinguish stored evidence from current eligibility.

Challenge the proposed mechanism

A collector lists O12 as unreferenced just before publication. Is a second list check enough?

Reveal the design reasoning

No, another publication can race after that check. Require a publication/collection authority rule that closes the race, such as an atomic lifecycle transition preventing later publication of a claimed object. Retain versions needed for rollback and restore.

Decision and reconsideration: Bind publication to immutable object identity and a guarded lifecycle. Change retention only with a concurrent-publication counterexample test.

Follow the publication state

  1. The client finished sending an image. May the catalogue mark it ready?

    Require the publication evidence

    Not on that statement alone. Verify the expected object and required checks, then publish the intended version under the application’s concurrency rule.

  2. Does S3 consistency make its upload atomic with a separate database update?

    Respect the service boundary

    No. The two operations can have different outcomes. The application needs an intent, observable intermediate states and recovery across that gap.

  3. An unreferenced object is found during a retry. Must it be deleted immediately?

    Check pending and retained uses

    No. It may belong to a pending publication or an allowed recovery version. Apply a deliberate cleanup contract that cannot race with valid work.

Publishing an object reference creates one discoverable representation. Page 18 follows another derived view—the search index—and asks when indexed results become eligible answers to the visitor’s query.

Northwind decision log

Separate object transfer from the ready-reference publication decision.
Retain intent and version identity through verification, retry and cleanup.
Pass only eligible published records and object references into search ingestion.

Go deeper: lifecycle and protection