Build the mental model
Every production app has three very different kinds of data, and treating them the same is one of the most common ways apps break after launch.
- Structured data (users, orders, comments) belongs in a database — transactions, indexes, consistent queries.
- Files (images, videos, PDFs, reports) belong in object storage — built for large binary blobs served over HTTP.
- Object storage is not a database, and despite appearances, it is not a folder on your server either.
Ephemeral disk eats uploads
A file saved to a production server's local disk — an uploaded avatar, a generated PDF — can silently disappear the moment the platform redeploys, restarts the container, or moves the app to a new machine. On many platforms this happens automatically on every git push.
A production database connection also carries higher stakes than a local one: real credentials, real customer data, network rules, and backup schedules all matter now.
Decide before writing upload code: database record, object storage file, or genuinely disposable data. Getting this wrong rarely shows up in development — it shows up in production, usually as a support ticket.
- Object Storage
- A system built to store large binary files (images, videos, backups) cheaply and serve them over HTTP, indexed by key rather than by folder path.
- Ephemeral Filesystem
- Local disk storage that can be wiped when a container restarts, redeploys, or moves to a new machine.
- Persistent Storage
- Storage that lives outside the app's own container and survives restarts and redeploys, such as a managed database or object storage bucket.
PRODUCTION DATA PATHS
---------------------
PRODUCTION DATA PATHS
----------------------
[ APP SERVER ]
| |
writes | | writes
v v
[DATABASE] [OBJECT STORAGE]
rows/tables files/images/videos
(structured) (blobs)
LOCAL DISK (container) MANAGED STORAGE
----------------------- -----------------------
EPHEMERAL PERSISTENT
wiped on redeploy/restart survives redeploy/restartConnect it to a real scenario
A tiny classifier makes the decision concrete: given a piece of data, decide which of three destinations it belongs to.
| Data kind | Where it belongs |
|---|---|
| image / video / document / backup | object storage |
| user-profile / order / comment | database |
| cache-value / session-token | ephemeral (ok to lose) |
Ask: would losing this on the next deploy be a disaster, an inconvenience, or a non-event? That answer almost always resolves the ambiguity.
Ephemeral disk eats uploads
Files saved to a platform's local/ephemeral disk can vanish on the next deploy — a genuinely common, costly beginner mistake.
Try the working example
function classifyStorage(type) {
const objectStorageTypes = ["image", "video", "document", "backup"];
const databaseTypes = ["user-profile", "order", "comment"];
const ephemeralTypes = ["cache-value", "session-token"];
if (objectStorageTypes.includes(type)) return "object-storage";
if (databaseTypes.includes(type)) return "database";
if (ephemeralTypes.includes(type)) return "ephemeral (ok to lose)";
return "unknown";
}
const items = [
{ type: "image", label: "user avatar upload" },
{ type: "user-profile", label: "username + email row" },
{ type: "cache-value", label: "rate-limit counter" },
{ type: "backup", label: "nightly database dump" },
];
for (const item of items) {
console.log(`${item.label.padEnd(28)} -> ${classifyStorage(item.type)}`);
}user avatar upload -> object-storage
username + email row -> database
rate-limit counter -> ephemeral (ok to lose)
nightly database dump -> object-storage5-minute try-it
Extend classifyStorage with two more types: 'export-csv' (a generated report a user downloads once) and 'auth-session' (a logged-in user's session state). Decide, and justify in a comment, which bucket each belongs to.
One important caution
Saving user uploads straight to the app server's local disk and discovering only after a redeploy that they are gone.
Treating a 'temporary' cache value as safe to lose, then quietly building real features that depend on it never disappearing.
MDN — HTTP and file uploads — Cloud & Deployment