Storing files outside the database

Put the file in object storage and keep only its key and metadata in the database. Databases are expensive per gigabyte and slow to back up when they hold large binaries.

Where it shows up in real systems

  • Object storage

    Practically unlimited capacity and eleven nines of durability, but each request takes tens of milliseconds and throughput is limited per key prefix. Put a CDN in front for public files; infrequent-access classes are cheaper to store but charge per retrieval.

    In production: Amazon S3, Azure Blob Storage, Google Cloud Storage, Cloudflare R2, MinIO

  • Shared file system

    Useful for legacy applications and content management systems that expect a disk. Each operation crosses the network, so it is much slower than a local disk and should not hold hot data or databases.

    In production: Amazon EFS, Azure Files, Google Filestore, NFS, CephFS

See it break, then fix it

Build an architecture, send it a day of traffic and outages, and learn why it holds or fails. Free to start.