Skip to content
We areTOP 1%

Why should images and videos be stored in object storage rather than in the database?

MediumConceptStorage & CDNs
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

Databases are optimised for small, structured, frequently queried records, while media files are large blobs that are written once and read many times. Keeping them in object storage leaves the database small and fast, and costs far less per gigabyte.

  • Pattern: upload the file to object storage, then save only its key, size, type and owner in the database.
  • Direct upload: the server issues a short-lived pre-signed URL, so the client uploads straight to storage and large payloads never pass through application servers.
  • Serving: place a CDN in front of the bucket so popular files are served from edge caches.
  • Processing: an upload event can trigger asynchronous jobs such as thumbnail generation, virus scanning or video transcoding.

More in Storage & CDNs

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account