قالب وردپرس درنا توس
Home / Tips and Tricks / How does Google’s Firebase Realtime database work? – CloudSavvy IT

How does Google’s Firebase Realtime database work? – CloudSavvy IT



Firebase logo

Firebase is a backend-as-a-service suite from Google designed to make mobile backends easy. Although it offers many features, the core is Firebase Realtime Database, a serverless database that can be scaled to millions of users.

What is Firebase?

Firebase is a whole series of products that offer many functions, such as simplified authentication, cloud management, machine learning, analysis and crash monitoring. However, the service that started it all is Firebase Realtime Database, a NoSQL database that clients can subscribe to via WebSockets.

Real-time data means that all updates made to the database are sent to client apps that subscribe to that data stream. A good example is a chat application ̵

1; new messages sent by user A will update the database, and user B and user C will receive these updates, where their client apps will display it as a new message.

Of course, this is possible without Firebase – MongoDB can achieve the same effect, and RethinkDB is based on the concept. But it is really a very nice feature to have, and in combination with all the other services it offers, Firebase makes a real alternative to building your own mobile backend.

In terms of actual data, Firebase is a document store database, much like other NoSQL databases that use this model, such as MongoDB. They are both schedule-free so you can store data in any format that suits your preferences.

Firebase is a database for databases where data is stored in a large JSON tree

Data in Firebase is stored in a large JSON tree. Each branch of the tree can be modified according to its own choice and changes in specific branches (e.g. /users/anthony/) can subscribe so that the client can listen for updates.

In JS, for example, you can get a reference to a specific database site, for example, like, count on a particular post. Then you can call ref.on() and give it a redial function to run when the Firebase client is sent an update

var LikesRef= firebase.database().ref('posts/' + postId + '/likes');
LikesRef.on('value', function(snapshot) {
  updateLikes(postElement, snapshot.val());
});

Of course, you can also download data only once if you do not need a real-time subscription.

Firebase will generally not be as efficient as your own dedicated database running on your own server, but it should be more than enough for most apps. If you’re looking for performance but still want to use the Firebase platform, you may want to look at Firestore – an alternative database solution in the Firebase suite. While both are still document databases, Firestore is a bit more structured. Instead of being a giant JSON tree, Firestore stores separate documents that can have their own structure. It can still be updated in real time, but is more suitable for applications that need to perform advanced queries.

Firestore is more comparable to a traditional database-like service, like AWS’s RDS, but you still do not have to worry about servers at all. To learn more about this, read Google’s overview of the differences between the two offers.

How much does it cost?

Firebase has a fairly generous free level for development and small apps. If you have less than 100 cooperating users and less than 50k / 20k daily read / write operations, you can use Firebase for free.

Once you have passed it, the price is salary as you go. You can use their calculator to decide how much to pay, depending on your usage. Pricing is based on GB stored and transferred per month for Firebase and per read / write operation for Firestore.

If you use other Firebase features, you may also be charged for them. For example, Hosting, Cloud Functions and Phone auth all have their own fees.


Source link