What is Firebase?
Firebase is a real-time database service provided by Google and operated in the cloud. It helps developers to quickly develop mobile applications by simplifying database operations.
Should it be used for large applications?
Firebase provides us with 2 main product groups focusing on 2 objects:
You are viewing: What is Firebase
- Develop & test your app: develop and test designed applications.
- Grow & engage your audience: Analyze data and optimize user experience.
If you are a newbie, learning to make apps with Firebase, or are using Firebase for small apps and feel good, you should skip this article. If you are considering using Firebase for large applications, storing data entirely on Firebase, then I hope this article will help somewhat.
A brief summary of Firebase's Realtime Database: real-time user data storage and synchronization. Applications that support this feature can store and retrieve data from the server very quickly. The data is stored in a database system that supports NoSQL and is located on the cloud server platform. Data is written and read with the lowest time in milliseconds. The platform supports synchronization of user data even when there is no network connection. Create a seamless experience regardless of the user's internet connection status.
Firebase is so famous that I won't have to introduce it anymore. And I only talk about its Realtime Database, not all. Let's consider the following case:
- You need to write an e-commerce application and use Firebase to store data, in the application with WishList feature.
- Users will be allowed to add multiple products to their wish list, as long as they don't overlap.
- How would you build the storage structure in Firebase to make this feature work as well as possible?
Solution 1: Each user has a key “wish_list”, which contains their favorite products
Related content: The art of dyeing Batik fabric - the traditional beauty of the Land of Ten Thousand Islands
This solution is the easiest, simply add the whole product object here. Need realtime just listen in wish_list of user logged in.
However, when we update the product (price, product status), we have to scan through all the users to update the product in their wish_list.
It takes a lot of time and bandwidth and data loses consistency very quickly. Also, this way the data is not flattened, which is not the best practice.
Solution 2: Create a separate WishList outside, in each item there is a UserID key to know who it belongs to.
This way is the same as the one above, but it saves you from having to scan all users, updating the product is much faster. However, this way is more annoying than I need realtime for WishList for only 1 user logged in, it cannot.
The client always receives the event every time any user on the system interacts with the WishList. This affects performance significantly.
Solution 3: Follow the RDBMS style, remembering only Product IDs.
Hot: What is IQ, OQ and PQ?
This approach has many implementations: array of productIDs per user, a separate object to map UserID and ProductID. Either way, when we get product information on WishList it is very troublesome. For example, wish list we have [1,4,8]3 products with comb IDs 1,4 and 8.
When we need to get the details of these products (for example, the user's wish list screen), we have to go get the product with the ID of 1, then 4, and then 8. But the function to get details it runs async so We have to use a group queue or equivalent programming technique to make sure we have fetched all the details for the above array….
Oh man, it's all because Firebase doesn't have queries to join objects or aggressive or map reduce. The above problem sounds quite simple, but it is encountered in many popular applications.
Not to mention applications with more complex data relationships. So should we use Firebase for large application?? Actually YES, but it's part of the system, not all. For example, a sales app can use Firebase for chat with store owners, updating real-time order status, for example.
Find the latest IT jobs here
See also: What is a Tooltip? 20 CSS Javascript Tooltip Examples For Websites
Post a Comment
Post a Comment