Choose a Database: Cloud Firestore or Realtime Database

Firebase offers two cloud-based, client-accessible document databases. Werecommend new customers start withCloud Firestore:

  • Cloud Firestore is therecommended enterprise-grade JSON-compatibledocument database, trusted by more than 600,000 developers. It's suitable forapplications with rich data models requiring queryability, scalability, andhigh availability. It also offers low latency client synchronization and offlinedata access.

  • Realtime Database is the classic Firebase JSON database. It's suitable forapplications with simple data models requiring simple lookups and low-latencysynchronization with limited scalability.

What are some other important things to consider?

After thinking about the previous key considerations, you might be ready tochoose a database.If you're still weighing advantages and disadvantages, this section covers otherdifferences betweenCloud Firestore andRealtime Database.

Data model

BothRealtime Database andCloud Firestore are NoSQL Databases.

Cloud Firestore[ PREFERRED ]Realtime Database
Stores data as collections of documents.
  • Simple data is easy to store in documents, which are very similar to JSON.
  • Complex, hierarchical data is easier to organize at scale, usingsubcollections within documents.
  • Requires less denormalization and data flattening.

Learn more about theCloud Firestore data model.

Stores data as one large JSON tree.
  • Simple data is very easy to store.
  • Complex, hierarchical data is harder to organize at scale.

Learn more about theRealtime Database data model.

Realtime and offline support

Both have mobile-first, realtime SDKs and both support local data storage foroffline-ready apps.

Cloud Firestore[ PREFERRED ]Realtime Database
Offline support for Apple, Android, and web clients.Offline support for Apple and Android clients.

Presence

It can be useful to know when a client is online or offline. FirebaseRealtime Database can record client connection status and provide updatesevery time the client's connection state changes.

Cloud Firestore[ PREFERRED ]Realtime Database
Not supported natively. You can build onRealtime Database's support for presence by syncingCloud Firestore andRealtime Database usingCloud Functions SeeBuild presence inCloud Firestore.Presence supported.

Querying

Retrieve, sort, and filter data from either database through queries.

Cloud Firestore[ PREFERRED ]Realtime Database
Indexed queries with compoundsorting and filtering.
  • You can chain filters and combine filtering and sorting on a property ina single query.
  • Queries are shallow: they only return documents in a particular collection or collection group and don't return subcollection data.
  • Queries must always return whole documents.
  • Queries are indexed by default: Query performance is proportional tothe size of your result set, not your dataset.
Deep queries with limitedsorting and filtering features.
  • Queries can sortor filter on a property, but not both.
  • Queries are deep by default: they always return the entire subtree.
  • Queries can access data at any granularity, down to individual leaf-node values in the JSON tree.
  • Queries don't require an index; however the performance of certain queries degrades as your dataset grows.

Writes and transactions

Cloud Firestore[ PREFERRED ]Realtime Database
Advanced write and transaction operations.
  • Write data operations through set and update operations as well as advanced transformations such as array and numeric operators.
  • Transactions can atomically read and write data from any part of the database.
Basic write and transaction operations.

Reliability and performance

Cloud Firestore[ PREFERRED ]Realtime Database
Cloud Firestore is aregional and multi-region solution that scales automatically.
  • A low-latency solution, with typical response times no greater than 30ms.
  • Houses your data across multiple data centers in distinct regions, ensuringglobal scalability and strong reliability.
  • Available in regional or multi-regional configurations around the world.
Read more aboutCloud Firestore performance and reliability characteristicsin theService Level Agreement.
Realtime Database is aregional solution.
  • Available in regional configurations. Databases are limited to zonal availability within a region.
  • Extremely low latency, with typical response times no greater than 10 ms. Anideal option for frequent state-syncing.
Read more aboutRealtime Database performance and reliability characteristicsin theService Level Agreement.

Uptime

Cloud Firestore[ PREFERRED ]Realtime Database
Extremely high uptime performance.
  • Typical uptime performance of 99.999%.
  • If availability is of the utmost importance, for example in ecommerce apps,useCloud Firestore.
High uptime performance.
  • Typical uptime performance of 99.95%.

Scalability

Cloud Firestore[ PREFERRED ]Realtime Database
Scaling is automatic.
  • Scales completely automatically. No limits on concurrent connections or overall database writes/second rate.
  • Haslimits on write rates to individual documents or indexes.
Scaling requires sharding.
  • Scale to around 200,000 concurrent connections and 1,000 writes/second in a single database. Scaling beyond that requires sharding your data across multiple databases.
  • No local limits on write rates to individual pieces of data.

Security

Cloud Firestore[ PREFERRED ]Realtime Database
Non-cascading rules that combine authorization and validation.Cascading rules language that separates authorization and validation.

Pricing

Both solutions are available on theSpark and Blaze pricing plans.

Cloud Firestore[ PREFERRED ]Realtime Database
Charges primarily onoperations performed in your database(read, write, delete) and, at a lower rate, bandwidth and storage.

Cloud Firestore supports monthlybudgets and alertsto avoid spending more than you are comfortable with.

Read more aboutCloud Firestore pricing plans.

Charges only forbandwidth and storage, but at a higherrate.

Read more aboutRealtime Database pricing plans.

UsingCloud Firestore andRealtime Database

You can use both databases within the same Firebase app or project. Both NoSQLdatabases can store the same types of data and the client libraries work in asimilar manner. Keep in mind the differences outlined previously if you decidetouse both databases in your app.

Learn more about the features available in bothRealtime DatabaseandCloud Firestore.

Ready to choose a database?

Hopefully this comparison has helped you settle on a Firebase database solution.Now you can learn how to add a database to your Firebase projects.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-05 UTC.