History goes back on Firebase database not too far beyond. Founded as a mobile and web development platform, Firebase was brought into existence in 2011 and then in 2014 it was acquired by the tech giant Google and its fate changed.
Skipping ahead of the history of the evolution of Firebase, within one year after its acquisition by Google, it was merged with Divshot and since then it has expanded to become a unified platform for mobile developers.
Firebase now integrates with various other Google services to offer broader products and scale for developers. In fact, the benefits that it offers makes Firebase for startups an in-trend process.
So what is Firebase database? Firebase is a BaaS, that is, Backend as a Service. Using the Products provided by Firebase, it is not just the Mobile developers who can build high-quality applications. Google has launched several new features for Firebase web users as well.
There are two products of Firebase which make it possible to build all the applications we just mentioned. Realtime and Cloud Firestore.
Realtime is the well-established product of Google’s Firebase database and Cloud Firestore, while promising better technologies, is still in its beta testing stage.
As per Google:
Realtime database is Firebase’s original database. It’s an efficient and low-latency solution for a mobile app that requires synced states across clients in real-time.
Cloud Firestore is Firebase’s new flagship database for mobile app development. It improves on the successes of the Realtime Database with a new, more intuitive data model. Cloud Firestore also features richer, faster queries and scales better than the Realtime Database.
Before coming to the individual properties of the Realtime Database and Cloud Firestore, let us have a look at what are the advantages and disadvantages of using Firebase database for your next project:
Advantages of Firebase Database:
If we have a look at the list of reasons, why one should use firebase database as their one-stop database for all the mobile and web app development, we will see why Firebase db has become such a big hit in the cloud solution services and mobile app development industry.
- Easy Data Migration – The recent developments have given the developers the tools to easily migrate the data out.
- No extra knowledge required – Almost zero knowledge is required about devOps or sysadmin to operate in Firebase db.
- Validation of various data types – Even though Firebase database structure is schemaless, it still has the basic ability to validate various data types.
- One-stop tool – It is an all-encompassing tool and the only one that you necessarily require for the backend of a small mobile application.
- Easier to use – The difficulty level of usage is a bit above average but it is easier than most other systems when it comes to integration with the analytics and crash monitoring
- Free Usage – It’s free in the initial phase so developers who are trying it out for the first time do not have to worry about making a big initial investment
- Rich Code Libraries – All the code libraries across programming languages are similar and well maintained for newcomers too.
- Fast development – Getting an application made from scratch is very fast – authentication, email, versioning, hosting, monitoring, DevOps, uptime.
- Easy streaming – Realtime functioning or streaming updates are very easy.
Let us now compare The Realtime database and Cloud Firestore to have a clearer understanding of when to use which. Cloud firestore is still in its beta testing stage and it is looking and working in a more promising way than Realtime database. In this comparison, will see how the two databases differ from each other and who wins the realtime database vs cloud firestore.
- Realtime database stores data as one large JSON tree which makes it very easy to store simple data but Complex or hierarchical data is harder to organise at scale.
- Cloud Firestore on the other hand stores data in the form of documents which are organised in collections. In this, storing of simple data is similar to JSON and it is stored in documents. Whereas, the complex or hierarchical data is not easier to organise at scale with the use of subcollections within documents. And overall it requires lesser denormalization and data flattening.
Real-time and Offline support
- Realtime database provides offline support for only the Android and iOS mobile clients.
- Cloud Firestore, on the other hand, provides offline support for Android, iOS and web clients as well.
- Realtime database provides deep queries with limited sorting and filtering functionality where the developers can either sort or filter on a property in a single query. And all the queries are deep by default, that is, the always return the entire subtree.
- Cloud Firestore indexes query with compound sorting and filtering where the developers can chain filter and combine filtering and sorting on a property in a single query. It is also possible to write shallow queries for subcollections, that is, developers can query within a document instead of an entire collection or an entire document. Not only this but the queries are indexed by default, it means that the query performance is proportional to the size of the result set and not the data set.
- In Realtime database, there are basic write and transaction operations. Write data works as an individual operation and Transactions require a completion callback in the native SDKs.
- Cloud Firestore allows Atomic write and transaction operations. It batches operations and completes them automatically. Also, transactions automatically repeat themselves until they’re completed.
Performance and reliability
- The realtime database is a mature product. It has the stability of multiple times tried and tested true product. It also has very low latency so it is a good option for frequent state-syncing. Although, databases are limited to zonal availability in a single region.
- Cloud Firestore performance can’t be measured yet because it is still in its beta stage. And stability in beta product is not the same as that of a fully launched product. But in terms of reliability, Cloud Firestore houses all your data across multiple data centres in different regions, ensuring global scalability and strong reliability. In theory, whenever Cloud Firestore comes out of beta, it will have a stronger reliability than Realtime database.
- In Realtime database, scaling requires sharding. To put it simply, Scale to approx 100,000 concurrent connections and 1000 writes/second in a single database and beyond that, it requires sharding your data across multiple databases.
- When Cloud firestore releases out of beta, scaling in it will be automatic and developers won’t have to shard their data across multiple instances.
- Realtime database has cascading rules that require separate validation. The firebase database rules are the only security options here and the developers need to validate data separately using ‘validate’ rule.
- Cloud Firestore has a simpler and more powerful security for mobile, web and server SDKs which use Identity and Access Management (IAM). Data validation also happens automatically. Also, rules can constraint queries, that is, if a query’s results might contain data that the developer doesn’t have access to, the entire query fails.
- The realtime database only charges for bandwidth and storage but at a higher price.
- Cloud Firestore, on the other hand, charges primarily on operations performed in your database (Read, write, delete) and at a lower rate, bandwidth and storage. It also supports daily spending limits for Google App Engine projects.
Are you still wondering how does firebase work? Let’s rewind a summary of what we have known in the above article.
When to use Realtime Database:
- If your data is simple and not complex or hierarchical
- If you need to scale under 100,000 concurrent connections 1000 writes/second in a single database
- When you need a database which charges for overall bandwidth and storage and not individual operations performed.
When to use Cloud Firestore database:
- If your data is complex or hierarchical
- If your data scales over 100,000 concurrent connections
- If you need a more precise spending limit and a database which charges primarily on 1 are PicCollage, Fabulous, Shazam and Skyscanner and we can all agree that they’re running successfully.
In conclusion, the Firebase db models have it going well for them. Realtime firebase has been running successfully for years now and last year with the release of beta version of Cloud Firestore, better things are in store of mobile app developers and app development companies.