Library / Case Studies

Ambry: Distributed Immutable Object Store at LinkedIn

A SREcon talk on Ambry, LinkedIn's distributed object store for immutable blobs: its architecture, key features and operational flows.

By LinkedIn engineers · LinkedIn · Added 2026-10-12

Open original source

All content belongs to LinkedIn engineers / LinkedIn. We only link to it and give credit. Report a problem

Learn this case study

About 37 min left. Your work is saved as you go.

What you are about to study

LinkedIn explains a real system. You should know the basics: caching, queues and replication.

Ideas you will meet

Distributed Systems
Consensus, time, failure and the fundamentals of scale-out.

What we already know about this

Our own lessons on these ideas. Read them here before you start, so it makes sense.

  • Real-World Systems · 9 minUploading large files reliablyChunked, resumable, direct-to-storage uploads: how to move gigabytes over unreliable networks without tying up your servers.Read here

    Why large uploads are hard

    A 5 GB file on a normal request has many ways to fail:

    • A single long connection dies on a flaky network, losing everything.
    • Timeouts in load balancers and proxies cut off long requests.
    • Your application servers are tied up carrying bytes, and memory or disk fills.
    • A failure at 99% means starting again.
    • Users want a progress bar and the ability to pause and resume.

    The design in one picture

    Figure SDA-RWS-17-1 · Chunked, resumable upload flow · © forcsguy.com

    Before: upload through your server

    After: upload straight to storage

    What changed

    • Your servers no longer carry large files
    • A failed chunk is retried, not the whole file
    • Pre-signed URLs keep storage private

    Step by step

    1. Initiate. The client tells the API the file name, size and type. The API checks permissions and limits, and creates an upload session with a unique id.
    2. Direct to storage. The API returns pre-signed URLs: short-lived, scoped links that let the client upload straight to object storage. Your servers never carry the file.
    3. Chunk. The client splits the file into parts (for example 5 to 100 MB; object stores typically accept thousands of parts per object) and uploads them, in parallel.
    4. Verify. Each part carries a checksum (MD5, CRC32C or SHA-256). The storage service or your server checks it, and a bad part is simply re-sent.
    5. Resume. The session remembers which parts are done. After a drop the client asks which parts exist and sends only the missing ones. Open protocols such as tus standardise resumable uploads.
    6. Complete. The client sends the list of parts; storage assembles the object.
    7. Post-process asynchronously. An event triggers virus scanning, type verification, thumbnails or transcoding, and metadata updates. The user sees "processing" until it finishes.

    Checking each part

    When a part arrives, the store replies with a checksum tag. The client keeps the list of part numbers and tags, and sends it with the final "complete" request, so the store can verify and assemble exactly the parts you meant, in order. A failed part is re-sent alone; assembly of a very large object can take a few minutes, so treat "complete" as asynchronous from the user's point of view.

    Smart extras

    • Deduplication: hash the file (or chunks) on the client first. If the content already exists in storage, skip the upload entirely and just add a reference (as in cloud file storage services).
    • Parallelism and adaptive chunk size: larger parts on fast networks, smaller on poor ones.
    • Compression for compressible data before upload.
    • Upload acceleration: send to the nearest edge location, which forwards over the provider's backbone.
    • Progress and cancellation: the client tracks bytes per part; cancelling aborts the session.

    Safety and cost

    • Limit size, type and number of concurrent uploads per user, and expire pre-signed URLs quickly.
    • Validate on the server, not only in the client: check file type by content, scan for malware, and store uploads in a quarantine area until cleared.
    • Use lifecycle rules to delete incomplete multipart uploads after a few days, since unfinished parts cost money until removed.
    • Encrypt in transit and at rest; do not let user-provided names choose storage paths.
    • Rate limit session creation to prevent abuse.

    Failure handling checklist

    FailureHandling
    Connection drops mid-partRetry that part with backoff
    Client closes the appSession persists; resume later by listing stored parts
    Corrupted partChecksum mismatch, re-upload that part
    Duplicate completion requestIdempotent: completing twice returns the same result
    Abandoned uploadLifecycle rule cleans up the leftovers
    Processing failsRetry from the event queue, mark the file as failed, tell the user

    Real-world reading

    Open this lesson with its quiz and exercise

  • Software Design Essentials · 9 minCreational patterns: Factory, Builder, SingletonWays to create objects without hard-wiring the exact class: factories, builders, prototypes and why Singleton is usually a last resort.Read here

    The goal

    Creational patterns manage how objects are created, so the rest of the code does not depend on exact classes or messy construction steps.

    Factory Method (and simple factories)

    Callers ask for what they need, and a factory decides which concrete class to create.

    interface Sender { send(to: string, text: string): Promise<void> }
    
    class EmailSender implements Sender { async send(to: string, text: string) { /* ... */ } }
    class SmsSender   implements Sender { async send(to: string, text: string) { /* ... */ } }
    
    function createSender(channel: "email" | "sms"): Sender {
      switch (channel) {
        case "email": return new EmailSender();
        case "sms":   return new SmsSender();
      }
    }
    
    await createSender(user.preferredChannel).send(user.contact, "Your code is 482913");
    

    Benefits: one place to change when classes change, callers depend only on the interface, and tests can supply fakes. A registry (a map from name to constructor) makes adding a type a one-line change.

    Factory Method as a picture

    Figure SDA-SDE-03-1 · Calling code, factory and products · © forcsguy.com

    Abstract Factory

    Create families of related objects that must be used together, such as a UI toolkit's button, checkbox and menu for one platform or theme.

    interface UiFactory { button(): Button; checkbox(): Checkbox }
    class DarkUi implements UiFactory { /* returns dark variants */ }
    class LightUi implements UiFactory { /* returns light variants */ }
    

    Use it when several products must stay consistent. Skip it when you only vary one object.

    Builder

    Construct a complex object step by step, especially with many optional parts. In languages with named parameters or option objects this is often just that.

    const request = new RequestBuilder("https://api.example.com/orders")
      .method("POST")
      .header("Authorization", token)
      .json({ items })
      .timeout(5000)
      .build();   // validates and returns an immutable Request
    

    Benefits: readable construction, validation in one place, and immutable results. The alternative, a constructor with ten positional parameters, is easy to misuse.

    Prototype

    Create new objects by copying an existing one, useful when creation is expensive or when you want variations of a configured template.

    const base = { retries: 3, timeout: 2000, headers: { accept: "json" } };
    const slow = { ...base, timeout: 10000 };            // shallow copy with a change
    const deep = structuredClone(base);                  // deep copy
    

    Beware shallow versus deep copies: sharing nested objects causes surprising bugs.

    Singleton

    Ensures only one instance exists and gives global access to it.

    class Config {
      private static instance?: Config;
      static get(): Config { return (Config.instance ??= new Config()); }
    }
    

    It looks convenient but has real costs: hidden dependencies, global mutable state, difficulty in testing (state leaks between tests), and trouble with concurrency. Often what you really need is one instance, not global access.

    Better: create the single instance once, in the application's start-up code (the composition root), and inject it into what needs it. You keep "only one" without making it global.

    Choosing

    SituationPattern
    Which class to create depends on input or configurationFactory Method or a registry
    Several related objects must matchAbstract Factory
    Many optional parts, validation neededBuilder or an options object
    Cloning a configured templatePrototype or a copy
    "There should be only one"Create one in the composition root and inject it

    Prefer the lightest form your language offers: a function that returns an object is often all the "factory" you need.

    Real-world reading

    Open this lesson with its quiz and exercise

  • Software Design Essentials · 11 minBehavioural patterns: Strategy, Observer, Command, StatePatterns for how objects cooperate: swapping algorithms, reacting to events, turning actions into objects and changing behaviour with state.Read here

    The goal

    Behavioural patterns distribute responsibility between objects and define how they communicate.

    Strategy

    Define a family of interchangeable algorithms behind an interface and pick one at runtime.

    type Pricing = (subtotalCents: number) => number;
    
    const regular: Pricing = (s) => s;
    const member:  Pricing = (s) => Math.round(s * 0.9);
    const blackFriday: Pricing = (s) => Math.round(s * 0.7);
    
    function checkout(subtotal: number, pricing: Pricing) { return pricing(subtotal); }
    checkout(10_000, member);   // the strategy is passed in
    

    Replaces long if/else or switch chains and supports the open/closed principle. In languages with first-class functions the "strategy" is simply a function you pass in.

    Observer (publish and subscribe)

    Objects subscribe to a subject and are notified when it changes, without the subject knowing who listens.

    class Emitter<T> {
      private handlers = new Set<(v: T) => void>();
      on(h: (v: T) => void) { this.handlers.add(h); return () => this.handlers.delete(h); } // returns "unsubscribe"
      emit(v: T) { this.handlers.forEach((h) => h(v)); }
    }
    const cart = new Emitter<number>();
    const stop = cart.on((count) => updateBadge(count));
    cart.emit(3);
    stop();                                              // always clean up
    

    Used for UI events, domain events and message buses. Watch for leaks (forgotten unsubscribes), ordering surprises and cascades of updates that are hard to follow.

    Observer as a picture

    Figure SDA-SDE-05-1 · One subject, many observers · © forcsguy.com

    Command

    Turn a request into an object containing everything needed to run it. That lets you queue, log, retry, schedule and undo it.

    interface Command { run(): void; undo(): void }
    
    class InsertText implements Command {
      constructor(private doc: Doc, private at: number, private text: string) {}
      run()  { this.doc.insert(this.at, this.text); }
      undo() { this.doc.remove(this.at, this.text.length); }
    }
    
    const history: Command[] = [];
    function perform(c: Command) { c.run(); history.push(c); }
    function undo() { history.pop()?.undo(); }
    

    Editors, job queues, macros and transaction logs all use it.

    State

    Let an object change behaviour when its internal state changes, by delegating to a state object (or a transition table).

    type State = "new" | "paid" | "shipped" | "cancelled";
    const next: Record<State, Partial<Record<"pay" | "ship" | "cancel", State>>> = {
      new:       { pay: "paid", cancel: "cancelled" },
      paid:      { ship: "shipped", cancel: "cancelled" },
      shipped:   {},
      cancelled: {},
    };
    function apply(state: State, action: "pay" | "ship" | "cancel"): State {
      const to = next[state][action];
      if (!to) throw new Error(`Cannot ${action} an order that is ${state}`);
      return to;
    }
    

    Makes illegal transitions explicit and impossible, replacing scattered flags and nested conditions.

    Template Method

    Define the skeleton of an algorithm in one place and let steps vary.

    abstract class Importer {
      run() { const raw = this.read(); const rows = this.parse(raw); this.save(rows); } // fixed order
      protected abstract read(): string;
      protected abstract parse(raw: string): Row[];
      protected save(rows: Row[]) { /* default */ }
    }
    

    Frameworks use it widely ("override these hooks"). With functions, you can pass the varying steps in instead of subclassing.

    Chain of Responsibility

    Pass a request along a chain of handlers until one handles it (or each adds something). Middleware pipelines in web servers are this pattern.

    type Handler = (req: Req, next: () => Promise<Res>) => Promise<Res>;
    // authenticate -> rateLimit -> validate -> handle
    

    Iterator and others

    • Iterator: walk a collection without exposing its structure. In most languages this is built in (for...of, generators).
    • Mediator: one object coordinates many (a chat room, a form controller) so participants do not reference each other.
    • Memento: capture and restore an object's state (undo snapshots).
    • Visitor: add new operations over a structure of object types without modifying them; common in compilers.
    • Interpreter: evaluate expressions of a small language.

    Choosing

    ProblemPattern
    Many alternative algorithms or rulesStrategy
    React to changes without couplingObserver
    Undo, queue, log or retry actionsCommand
    Behaviour depends on lifecycle stateState
    Same steps, different detailsTemplate Method
    A pipeline of optional processing stepsChain of Responsibility

    Remember: with first-class functions many of these become callbacks, closures and tables. Use the lightest form that keeps the code clear.

    Real-world reading

    Open this lesson with its quiz and exercise

Go deeper on this

A path through videos, articles, other case studies and code on the same ideas as Ambry: Distributed Immutable Object Store at LinkedIn.

  1. Warm upGet the vocabulary first.

  2. WatchHow others solve the same problem, on video.

    Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)

  3. ReadEngineers explain it in their own words.

  4. See it in another companyThe same ideas, a different system.

  5. Read the codeSee how it looks when it is real.

Keep learning

Loading community…