Lesson 15 / 25
When to Use Storage and Realtime
Fit, limits and alternatives.
By Rahul Agarwal · 15 years in web development
Pick the lightest tool
Store large binary files in Storage and keep only their paths in tables. Use Postgres Changes for modest volumes of row-level updates such as dashboards or task boards; for high-traffic feeds, Broadcast (optionally sent from the database) scales better because every Postgres change must be checked against RLS for each subscriber. Simple refresh-on-focus or polling is often enough when updates are rare. Connection and message limits depend on your plan, so check the docs and pricing page.
A decision sketch
Rules of thumb.
# images, PDFs, video -> Storage (save the path in a table)
# few users watching row edits -> Realtime Postgres Changes
# chat, cursors, typing, high message rate -> Realtime Broadcast
# who is online in a room -> Realtime Presence
# data changes rarely -> refetch on focus or pollNever store files as base64 in rows
Large blobs bloat the database, backups and every query; Storage and a CDN serve them far more cheaply.
Quick check: Where should a user-uploaded video be kept?
- In Storage, with its path saved in a table
- As base64 in a text column
- In a Realtime channel
- In an environment variable
Answer
In Storage, with its path saved in a table — Keep blobs out of the database.