Read a List of All Firebase Inputs Api
Edifice real-time applications is today standard. At Crisp, we used Firebase in production over nine month, starting from day one. From the dream to the nightmare, hither is our experience.
Annotation that this commodity covers the production aspect of using Firebase Realtime Database, and we yet remember that this solution even so great to build MVPs, Hackathon Projects, or if you take your own reasons.
Edit: Firebase reached us and was very receptive to the problems we encountered. We are glad to see such an engaged team for their product. Our case is special as we take very specific needs for which we got to the limits of Firebase (which was past the way the pre-2016 Google I/O version). Nonetheless, this is an excellent service if all you need is storing user data and dealing with real-fourth dimension issues.
The Project
Our Initial (Good) Reasons To Utilize Firebase
Crisp is a a dead-simple live chat focused on user-experience. We wanted to brand a cost-effective solution so we decided to utilize a Socket.IO backend to bargain with live-chat on websites and in the same time, using Firebase for our dashboard, all synced with AMQP on the backend-side.
This hybrid architecture immune the states to build the MVP in only iii weeks, both the live chat and the dashboard, used by separate people in the same fourth dimension, and get information technology to communicate with micro-services. This server-less MVP dashboard immune the states to focus on UI and UX rather than server code, and this was actually a good thing at that point.
We bootstrapped the product apace and got to market early on. Exactly what yous'd desire with an MVP.
Then Came The Storm
Kickoff few months went great, and then boom. Nosotros got featured on ProductHunt. Nosotros had a corking growth, but with it came our outset calibration issues.
From a huge nugget, Firebase became a nightmare, slowing down our execution. Building new features was deal-breaker and nosotros had to think twice before releasing new things in production.
Nosotros discovered Firebase technical limits as well, as we encountered performances bug when we scaled to 100GB+ Firebase traffic every calendar month.
10 Reasons To Switch
i. Spaghetti code
Server-less, doesn't mean lawmaking-less! Using Firebase ways that all your server logic is now running right in your spider web or mobile client.
In most of apps, you lot take to ship welcome emails, process images (avatars, etc), deal with payments, and build your business concern-core features. You really don't want all those to be done on the client, as this can range from impossible to dangerous for your business organisation.
These things may still be "hacked" using Firebase, but it means that you will have to add fifty-fifty more than lawmaking to your web-app, and information technology could exist a nightmare to maintain if y'all have a mobile app as well.
Think about distribution: any database logic change results in client app updates. How do yous deal with clients who didn't update? Is it a correct thing to do for your users to deactivate older clients to force update?
ii. Integrating Firebase with micro-services is infernous
At Crisp, we use micro-services, and in many-cases you have to query a database, to get user information, IDs, etc.
Firebase tin can be both used from the client (eg: Web, mobile apps), but too from the backend (eg: NodeJS). You may query directly Firebase over the network, right from your backend, but yous should avert doing this because it is really tedious at scale.
Nosotros used Redis to cache all these operations, pregnant that we had to synchronize all the information back-and-forth. The micro-service doing this job (in other words - connecting to Firebase) had memory bug because Firebase caches data in memory and don't seem to release all unused references (nosotros used the Firebase NodeJS library).
3. Pricing
Server-less doesn't mean cost-less. No, no, no: one mean solar day you will have to pay for your laziness. Indeed, we had to when nosotros received this email from Firebase:
Firebase paid tiers come up with a usage quota, plus overage fees if you lot exceed the program limit. Your Firebase, crisp-<..>, has been exceeding its programme'due south limits, and, due to an fault on our end, y'all accept not been charged overage fees. We will exist correcting this beginning adjacent week, which will outcome in your business relationship being charged for whatever backlog usage.
[..]
Thanks so much for being a Firebase customer!
Give thanks you for the post, Firebase!
Paying $100 per month for something you lot can run on a $5 DigitalOcean droplet is something that get you to think twice when dealing with server-less code.
With your own server code, you volition gain maintainability and productivity and you will have a cost-effective code-base.
4. Firebase downloads all subtrees on load
Assuming that you are building a Slack-like app, you will have to download all channels data on app load.
Some people volition say that it could be something improved with pagination, but with Firebase, y'all cannot paginate because you lot cannot get query array length, you cannot paginate ordered arrays, etc...
5. Yous might have inconsistencies
Firebase supports offline operations. It's works like "git commits", but the main event is that if you lot client goes offline and then online and you have concurrency on some input information (for example, a shared notepad), you might have inconsistencies. Pretty much like Git merge conflicts.
6. The problem of information migration
With Firebase, you can't deal easily with data-migration like you can practice with a simple SQL database, an ORM or ODM.
This means that y'all volition accept to exercise things like such:
if (user && user.new_subdocument && user.new_subdocument.new_property) { // Do stuff. }
Resulting in rubber weather condition, everywhere.
vii. Relations are marvelous
Dealing with relations with NoSQL is hard, dealing with relations with Firebase is pain in the ass.
For instance: an user belongs to a squad, and a squad has users.
User:
{ proper noun : "John Doe", team_ids : [...] }
Team:
{ name : "Pinnacle Inc", user_ids : [...] }
It means that you user has to spotter team_ids, then populate on your own teams and your team has to watch user_ids and populate users. This instance is unproblematic. Picture the whole affair with more relations, and yous get a spaghetti logic.
8. Queues are buggy
To bargain with server code and micro-services, Firebase introduced queues to share operations between server and preclude concurrency (eg: to avoid sending an e-mail twice).
The NodeJS library implementing Firebase queues is named: firebase-queues.
This characteristic was not well maintained by Firebase teams, and we had several bugs, including synchronization issues, locks, etc.
Likewise, queues were a scale clogging as queue items tin can be inserted (stacked) apace, but consumed (unstacked) very slowly. If your connected clients insert more than your backend is able to process (which is seems to exist express by the firebase-queue library timers, and not your CPU or network), this will result in huge processing delays that are not adequate when dealing with existent-time applications. Furthermore, I've just described a potential DOS assault vector: connect to a client and alluvion the queue with records, and the whole queue tasks will be greatly delayed, such that the service becomes unusable.
So yes, avert Firebase queues.
9. Y'all don't ain your data
Beside the fact that your data is hosted on servers that you lot don't own, information technology'southward non possible to consign your user data. You can't consign emails, and user accounts are not recoverable (you cannot export user accounts with passwords).
Plus, information technology was non possible to consign our data when we had hundreds megabytes hosted. Nosotros had to contact Firebase past e-mail.
Discover: exporting information email/password information is possible past contacting Firebase Team, but not from Dashboard.
ten. Circuitous queries are impossible
It's yet impossible to query your database to find fields with some properties.
For instance, y'all want to build a Slack-like app: you cannot count unread messages, even if you lot take the proper structure that would permit to do so (eg: a read = <true|false> tag). The hack is to count all unread messages client-side, after having retrieved the whole dataset. It'southward a huge performance upshot.
Yous can't perform operations to go active users, or doing batch operations to update documents having some fields.
Bonus. Desire to build an API for your production? It'south impossible.
Today, most apps expose a developer API. This is impossible to practice with Firebase.
Of course, you could notwithstanding remotely query your Firebase database upon receiving API requests from clients, but this would be extremely dull every bit the data is hosted remotely and the Firebase libraries are leaking memory (run across above).
The second solution is to make an HTTP wrapper. All that said, in this instance the best option is build your API with standard storage backend yous host, using your own database systems (relational or not-relational). This is what we did.
Migration
Architecture
We decided to migrate to a Residuum API. To brand things simple, we chose to use an old-fashioned SQL Database, which overs 90% of our data storage needs. It has relations, models, and information technology's perfect to make a impenetrable, simple, and maintainable API. You tin read our API docs here
For the ten% role, we decided to use MongoDB to store messages and conversations at scale. We used UUIDv4 as master keys, both in MongoDB (this is the de-facto standard in MongoDB) and into our SQL DB (this is not the standard in the SQL globe) to go far transparent for everybody.
All Grime (Create/Read/Update/Delete) operations are performed over the REST HTTP layer and some asynchronous replies (after some API requests) are send back over a Websocket layer (nosotros call it our Realtime API).
Updates are internally forwarded over AMQP and and so synced with a Socket.IO micro-service, and an authentication layer filters ressources that you are subscribed to.
Simple, constructive, and sustainable. We are now gratis to switch from Socket.IO to another engine, or even migrating from MongoDB to some other data store.
Let'south Code
Started to build the API from Paw (a Postman-like app, for Mac), by mocking API routes and simulating things. Then, nosotros made it working with real code. Nosotros used NodeJS but you could use PHP, Cerise or every linguistic communication that you and your team are happy to piece of work with.
At the aforementioned fourth dimension, we removed all Firebase logic from our apps to remove all logic from the client and plugged all network operations over our API. The complication should be implemented in the server.
These two parts took effectually iii weeks, then came our migration scripts, migration tests, and production migration.
Let's Exhale Again
This migration allowed us to focus again on execution and several things were improved into our product:
- Web app loading time were reduced from 20 seconds for some users with many conversations to 2.5 seconds (constant fourth dimension, regardless of how many chats you accept).
- Features like search, pagination, and more are now possible because: MongoDB.
- The lawmaking of our apps became elementary once more.
- Making mobile apps became unproblematic, besides.
- Migrations are now easy thanks to schemas and ORM.
- We can query our data-bases to update so inputs when needed (applying a discount, etc).
- We now have a developer API.
- If you read this one, you lot'll accept a -thirty% discount on all Crisp paid plans forever (use coupon code
IHATEFIREBASE
).
Cheers for reading, and now, think twice before using Firebase!
johnsonhistogives.blogspot.com
Source: https://crisp.chat/blog/why-you-should-never-use-firebase-realtime-database/
0 Response to "Read a List of All Firebase Inputs Api"
Publicar un comentario