Library / Case Studies

Fleet Management (3 parts) at Spotify

This is part 3 in our series on Fleet Management at Spotify and how we manage our software at scale. See also and .

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

Open original source

All content belongs to Spotify engineers / Spotify. 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

Spotify 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

Want the architecture first? Read our Spotify case study, with its diagram.

Go deeper on this

A path through videos, articles, other case studies and code on the same ideas as Fleet Management (3 parts) at Spotify.

  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…