Choose Firestore, Bigtable or Memorystore
Match Firestore, Bigtable and Memorystore to schema, access pattern, consistency, data lifecycle and cost for a given workload.
By Invicly Tech, , in Google Cloud Engineering and Services. About 8 minutes to read.
In short
Firestore stores documents for apps with flexible, query-by-field data. Bigtable stores huge, sparse tables read by row key at very high rates. Memorystore is an in-memory cache that sits in front of a slower database. Pick by access pattern, not by habit.
Think of it like this: Firestore is a filing cabinet of folders, Bigtable is a giant ledger you read by page number, and Memorystore is the sticky note on your monitor.
Explained simply
Not every workload fits tables and SQL. Google Cloud has other stores built for particular shapes of data and access. Choosing well starts with one question: how will this data be read?
Firestore stores documents, which are bundles of fields kept under an ID. It suits app data such as user profiles and carts, where screens read a few documents at a time. Queries are fast because they use indexes that Firestore keeps for you.
Bigtable is for very large amounts of data read by key, such as sensor readings or click streams. You can only look things up by row key, so the key design is the whole design.
Memorystore is a cache that keeps copies of popular data in memory so reads are quick. If it loses data, the app reads again from the real database. That is why every cached item gets a time limit, called a TTL.
Press Play on a diagram to walk through it one step at a time.
- Documents in collections
- Queries use indexes
- Strongly consistent reads
- Billed by reads, writes and storage
- Wide-column, row key only
- Single-digit millisecond at scale
- Needs a careful key design
- Billed by nodes and storage
- In memory, very fast
- Data can be rebuilt from source
- Redis or Valkey engines
- Billed by memory size
- App to Memorystore: Get order:421Get order:42
- Memorystore to App: Miss2Miss
- App to Database: Read order 423Read order 42
- Database to App: Row returned4Row returned
- App to Memorystore: Set order:42 with 300 second TTL5Set order:42 with 300 second TTL
- Documents by ID or filter, small to medium scale
- Firestore
- Huge volume by row key or time range
- Bigtable
- Same answers read again and again
- Memorystore in front of a database
- Joins and transactions across tables
- Cloud SQL, AlloyDB or Spanner
In depth
Modelling documents in Firestore
Design documents around the questions your screens ask. A document can hold nested fields and small lists. Collections group documents, and a document can have subcollections. Reading one document is cheap and fast; joining across many is not, so copy a small amount of data into the place it is read.
Firestore creates single-field indexes automatically. Queries that filter or sort on several fields need composite indexes, which the error message tells you how to create. Document size is limited to about 1 MiB, and one document should not be updated at a very high rate.
- Model for the read, not for tidiness
- Add composite indexes when a query asks
- Keep documents small
- Use the local emulator for development
Designing Bigtable row keys
Bigtable stores rows sorted by key and spreads ranges of keys across nodes. Reads by key or key range are very fast. If every new key starts with the current time, all writes go to the last range, one node, and that node becomes a hotspot.
A better key starts with something that varies, such as a device ID, then adds time. Related rows sit together, so a range scan gets one device's recent data. Bigtable guarantees atomic changes to one row only, so keep related data in one row.
- Device ID
- spreads writes across nodes
- Reverse timestamp
- newest rows sort first
- Column families
- readings
- status
Caching, TTLs and cost
Memorystore offers managed Redis-compatible and Valkey engines; check the console for what is available in your region. The usual pattern is cache-aside: read the cache, on a miss read the database and store the result with a TTL.
Data lifecycle differs by store. Firestore can expire documents with a TTL policy on a timestamp field, and deletion is not instant. Bigtable uses garbage collection rules on column families by age or number of versions.
Costs follow different meters: Firestore charges per operation, Bigtable per node hour, and Memorystore per memory provisioned.
Learn it in 5 short steps
About 30m each. Track them with a timer in your plan.
- 1Model documents in Firestore~30m
- 2Design Bigtable row keys~30m
- 3Cache reads with Memorystore~30m
- 4Set TTLs and data lifecycle~30m
- 5Compare cost drivers~30m
Key points
- Firestore suits user-facing app data. Model documents around the screens that read them, and expect to add composite indexes.
- Bigtable has one index: the row key, sorted in order. Avoid keys that start with a timestamp, which sends all writes to one node.
- A cache holds copies, never the only copy. Set a time to live (TTL) so stale values expire.
- Firestore has TTL policies on a timestamp field. Bigtable uses garbage collection rules by age or version count.
- Cost drivers differ: operations for Firestore, node hours for Bigtable, provisioned memory for Memorystore.
Key terms
Tap a card to flip it. 0/5 known
Examples
Bad: 20261202T101500#device-17
Good: device-17#20261202T101500
Better for newest-first reads:
device-17#<reverse-timestamp>
Device IDs spread the writes; the suffix keeps one
device's readings together for a range scan.Bigtable row keys for sensor readings. Lead with the device, not the time.
Cache-aside with a local Redis
Prerequisite: Docker. This models Memorystore with a local Redis container. Set a value with a 60 second TTL, read it, and watch it expire. Cleanup: stopping the container removes it.
docker run --rm -d --name cache -p 6379:6379 redis:7
docker exec cache redis-cli SET order:42 '{"total":19.99}' EX 60
docker exec cache redis-cli TTL order:42
docker exec cache redis-cli GET order:42
# after 60 seconds the GET returns nothing
docker stop cacheFirestore emulator for development
Prerequisite: gcloud with the emulator component. The emulator runs locally, needs no billing and discards data on exit. Evidence: your app connects without any credentials. It does not copy every production limit or security rule behaviour exactly.
gcloud emulators firestore start --host-port=127.0.0.1:8080
# in another terminal
export FIRESTORE_EMULATOR_HOST=127.0.0.1:8080
python app.pyQuick reference
- Firestore: documents, automatic single-field indexes, composite on request.
- Bigtable: one index, the row key. Avoid timestamp-first keys.
- Bigtable atomicity is per row only.
- Memorystore is a cache: set a TTL, keep the truth elsewhere.
- Firestore cost: operations. Bigtable: nodes. Memorystore: memory.
- Firestore TTL policies delete expired documents with some delay.
Common mistakes
- Using Bigtable for a few gigabytes of data. A node costs money all day; Firestore or SQL is usually cheaper.
- Caching without a TTL or an invalidation plan, so users see old data.
- Reading many Firestore documents on every page load, then being surprised by the bill.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Using the local Redis model, store a value with a 30 second TTL and confirm it counts down.
- Exercise 2medium
Design a Bigtable row key for delivery events where you mostly read the last hour of one courier.
- Exercise 3hard
Plan the data stores for a shop: carts, product catalogue reads, order history and clickstream. Justify each choice.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Is Firestore the same as Firebase?
- Firestore is a database you can use from Firebase apps or from Google Cloud directly. Firebase is the wider toolkit.
- When is Bigtable too much?
- When the data is small or you need joins. A Bigtable cluster bills for nodes all day, so use it only for large, key-based workloads.
- Does a cache make data inconsistent?
- It can serve slightly old values. A short TTL or deleting the key on update keeps it close to the database.