Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'd like to use just a single method of persistence in my app, and am using Cloud Firestore for my premium/paying users.
Is it possible to also use Firestore in offline only mode for free users so that I don't incur costs?
Cloud Firestore is an online database that continues to work when you're offline for short or longer periods of time. But it's still primarily an online database, and should not be used as a fully offline database.
One reason for this is that Firestore keeps the local mutations in a separate queue until they've been committed to the server. When a query/read hits the local data, the Firestore client combines the cached reads that it got from the server, with the local mutations. As the queue of local mutations grows, this operation gets slower. As long as the client occasionally synchronizes the data to the server, this slow down won't be significant. But if you use Firestore as a fully offline database, it will become prohibitive over time.
For a good explanation of how the Firestore client works under the hood, have a look at these (long) code comments in the Firestore JavaScript SDK:
the persistence class, which is responsible for storing the data on the local disk
the local store class, which handles (a.o.) the reading from both the local cache and the local mutations.
If you need offline database, do not use Firebase. Firebase will cost you huge money in the future. Read this full article from an unhappy Firebase customer with 3+ years Firebase usage experience.
Sadly, We've been using Firebase for our Goal Meter app (Android and iOS), Weight Meter app (Android). Our users have grown over years and now we have about 100,000 active users for our Goal Meter app. About %95 of them are free users. The cost of Firebase database is growing rapidly and we cannot prevent free user data from syncing into Firebase online database. We've decided to change to another company for our future project.
Don't make the same mistake that we did. If your app needs offline database (I guess most apps do need it), then by any means avoid using Firebase. Move to other solutions such as AWS.
I've already contacted the Google Firebase team regarding this ridiculous issue. I can only imagine one scenario why Google Firebase team is preventing the full offline capabilities. The reason is because Firebase team is greedy. After all, if the database is offline, how can they make you pay? We've been in love with every single product from Google. We even produce Android version before iOS one, in order to support Android and Google. Firebase product is amazing, but this "purposefully" disabling offline capabilities is a shame. A shame for Firebase team and Google in general.
An alternative approach is allow users to create accounts and offer a trial period. If they decide to sign up for premium access, all the data is already synced to Firestore. This doesn't solve your want to have local only access, but could be a different option you could take.
Related
This question already has an answer here:
What is the best practice for a multi-tenant app with Collection Group Queries in Firestore?
(1 answer)
Closed 2 years ago.
I designed an app and all the auth is done with Firebase along with storing documents. I have everything working perfectly but the app right now is set up for one database.
This will not work because The app will be used by multiple organizations who will have their own users and data which should be separated in another database? My question is how do I go about setting my Flutter App and Firebase to handle multiple organizations.
I just don't understand how the login page in the app would know what database to log in to. It would have to somehow be connected to the user.
Any push in the right direction is greatly appreciated.
Thanks!
If this a commercial app you are developing and customising for your customers, where each company supposed to have their own circle of users, you should always separate the database as well as the codebase (project), for various reasons which include potential data breaches, privacy etc. As a responsible and accountable developer, avoid reusing the same infrastructure for multiple customers.
If this is just a normal app that behaves like those apps we downloaded from the app store, then it shouldn't be a problem as Firebase Auth can handle it. Just apply the Firebase Security Rules to restrict the content.
I am creating an android quiz app, the core features of the app are
database user registration and login(registering a minimum of 100k users)
several databases(about 10) for different quiz categories holding about 500k+ questions in total to be retrieved by the user only when there is an internet connection on the android device
i need the app to be really secure as it would also be using credit card information
my question here is which would be better for the database,
using xampp(php, mysql and apache) or using google firebase? and why?
and is having 10 databases for 10 diffrent categories efficient, or can i have one database for the 10 categories?
1st. xampp is fully own your dedicated server, so you will need monitoring
and execute everytime whenever you need to do.Very need time for adding new feature next.
firebase is public server you can use free maintenance and troubleshoot. much feature their offer.push notif,authentification and etc.and it safe and secure for business.for further information you can visit firebase console site,
2nd. 10 database for 10 categories. it mean 1 database for 1 categories. you can call your database based your user request.
conclusion : it depending your technical skill and your exeperience to choosing an online service. if you try develop an app earn money. dont forget put an Ads space. so you can earn money for it.
I am currently using Firebase Firestore as a primary backend that retrieves data from a variety of sources. I also use Android's Room for my mobile backend. When the phone receives data it is stored in the Room database in the event the user will not go online again for days even weeks.
After looking through the device files, I see firestore saves the data in files under the /data/data/<your-app>/databases directory.
The file looks something like this
I have read the offline persistence docs on the firestore and there is no indication on how durable the offline persistence is It mentions that the data is cached but not for how long. My question is, what is the durability of Firestore's offline persistence. Would one recommend using it instead of having a fully-fledged local DB to store data that may not be synced over long periods of time (days,weeks)?
It seems to already handle syncing data well once a connection is re-established. Im just worried that after some point that file may be deleted by the system and the user loses everything.
On Android (as of this writing) Firestore uses SQLite as a persistence mechanism. So for intermittent periods of offline activity you should have no problems with performance or durability.
However if you are going to be offline for days or weeks (as you said) there are some things you should be aware of:
Performance
Because Cloud Firestore is meant to be used mostly online, pending writes that have not yet been synced to the server are held in a queue. If you do many pending writes without going online to resolve them, that queue will grow and it will slow down your overall read/write performance. Most of Cloud Firestore's performance guarantees come from indexing and replication on the backend, but most of those optimizations don't exist when you're operating offline-only.
Conflicts
Firestore's basic conflict resolution model is "last write wins". So if you have many offline clients writing to the same document, only the last one to come online will actually "win" and persist their change.
Features
Most of Firestore's features work offline with one major exception: transactions. Transactions can only execute when you are online. So if your app uses transactions it will not work properly offline without some special handling.
There is no indication in offical documentation on how durable the offline persistence is because it cannot be predicted. This question cannot have an exact answer, like 4 weeks or something like this because it depends on how many write operations take place while you are offline.
I recommend you not to use Cloud Firestore as an offline-only database. It's really designed as an online realtime database that can work for short to intermediate periods of being disconnected.
While offline, it will keep queue of all your write operations. As this queue grows, local operations and app startup will slow down. But you need to know that these operation will persist even if you restart the device. You not gonna lose any data.
This question already has answers here:
What's the difference between Cloud Firestore and the Firebase Realtime Database?
(5 answers)
Closed 5 years ago.
On the firebase console a Cloud Firestore tab has been added and going through the documentation it has some similar features like Realtime database. My android app already uses the Real-time database, functions, and storage and everything work fine. I would like to know how the Cloud Firestore can make my application better and what are the special features present only in Firestore that are not there in the real-time database that could improve my application.
I have a chat based application running on the real-time database and I am performing very frequent requests for small amount of data. Will switching to Firestore reduce my cost? Will it maintain or increases the speed of operation?
A developer advocate answers in blog post
The main points:
Better querying and more structured data
Designed to Scale
Easier manual fetching of data
Multi-Region support for better reliability
Different pricing model
The Cloud Firestore is an upgrade on the Real-time database although the Cloud Firestore is still in beta.
The Cloud Firestore offers
Better and faster data queries. With the C. Firestore, data at the top collections can be fetched without grabbing any sub-collections in its children node. This prevents downloading unwanted data from your db unlike the real-time db.
Scalability: The above already explain why this is more scalable.No matter how large your db is, your app will only request for necessary data unlike the real-time db.
Read more: https://firebase.google.com/docs/firestore/rtdb-vs-firestore
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
What are the differences between a local database and a server database?
I think you know the basic answer:
-Local Database: the database is located on the User's Android Device.
-Server Database: the User's Android Device must connect to an external server to access the database.
Here is my real world example of my usages of both:
I was tasked to develop an app for "Secret Shoppers" employed by Sam's Club. Basically they had to go to different grocery stores, and report prices using the app, and that data must be saved in Sam's Clubs Databases (On THEIR Servers). Here was 'the catch', not every Secret Shopper had a tablet with a 4g network, thus could only transfer the data while they were on WiFi.
So what I did was create an exact clone of their databases using SQLite, every time they 'submitted' a report of products and prices:
First I checked that the User's Android Device had internet access.
If they DID HAVE internet at the time of submitting, the report would be sent to Sam's Club servers as normal.
If they DID NOT HAVE internet at the time of submitting, the report would ONLY save on the LOCAL Database on the Android Device with a FLAG indicating it has not been sent to Sam's Club Servers.
When the app is run with internet, it will then send the those flagged reports to Sam's Club Servers.
So basically, I used a LOCAL Database that SYNCS with a SERVER Database each time the app is run. Hope this helps with the 'picture' you are looking for in terms of Local vs Server in Android Development specifically.
Local database would be SQLite in android. It can be accessed locally only.
A server database is hosted in a remote server. Basically It can be accessed by any client in the web.
An example of local use would be for example storing credentials or information that you don't want/need to share with another user.
You can use local database to create a backup of the server database in order to access your information even if you don't have a reliable internet connection o make your app faster by not downloading data every single time you need it and using the one store locally.
For example Facebook is saving everything in a server database so you and millions people around the world can accesses to that information.
The local database is Local (offline) & the server database is online
This is the biggest difference, It all depends on your app style
If you want a dynamic application you should use online database
else
you can use both of them for static data