Practice: Shoply's Data
Which store for what.
Shoply is now big. It has users, orders, product photos, a search box, sessions, and a dashboard of sales per minute. Pause, and decide where each one should live.

- Users and orders
- Photos, search, sessions
- Sales per minute
One possible answer
Here's one answer. Users, products, and orders go into Postgres, because they're related and need transactions. Product photos go into object storage, behind a CDN. Search uses Elasticsearch, fed from Postgres. Sessions and carts use Redis. And the sales dashboard reads from a time series database.
| Data | Store | Why |
|---|---|---|
| Users, orders | Postgres | relations, transactions |
| Photos | S3 + CDN | big files |
| Search | Elasticsearch | full text |
| Sessions, carts | Redis | fast key lookups |
| Sales per minute | Time-series DB | metrics |
Keeping them in sync
With several stores, keep them in sync carefully. Postgres is the source of truth. Changes flow out to the search index, often through a message queue, which we'll meet soon. Redis data can be lost and rebuilt. And photos are referenced by keys stored in Postgres.
| key | value |
|---|---|
| Source of truth | Postgres |
| Search | fed by change events |
| Redis | can be rebuilt |
| Photos | keys in Postgres |
Summary
Real systems use several stores, each for what it does best, with one clear source of truth. Next, a quiz on databases.
Key takeaways- Right store for each job
- One source of truth
- Sync with events