Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore offline data: Merging writes, maximum time of offline persistence

https://firebase.google.com/docs/firestore/manage-data/enable-offline

How does Firestore work with offline data?

  1. How are writes merged by many clients editing the same data offline, that then come online at the same time?

  2. How long is offline data persisted? If my user uses my app for 5 years offline, then comes back online, will this be an issue? Do offline changes persist after device restarts?

  3. Does query performance of offline data degrade as the data set gets larger?

Im specifically interested in the web Firestore client.

Do all the language clients implement the above in the same manner?

Thanks.

like image 435
zino Avatar asked Nov 04 '17 13:11

zino


1 Answers

How are writes merged by many clients editing the same data offline, that then come online at the same time?

The write operations that will take place on Firebase servers, will be in the order in which that series of operations happened. The last operation (the most recent one) will be the one that will be available in the database by the time the synchronization occurs.

How long is offline data persisted? If my user uses my app for 5 years offline, then comes back online, will this be an issue?

The problem is not about how long is about how many operations do you make while the device is offline. While offline, Firestore will keep in queue all the write operations. As this queue grows, local operations and app startup will slow down. Nothing major, but over time these may add up. The major problem in this case is that the end result of this will be that the data on the server stays unmodified. Then what is the purpose of a realtime database? Firestore is really designed as an online database that came work for short to intermediate periods of being disconnected, not to stay offline for 5 years. Beside that, in 5 years it might be a problem of compatibility and not of the number of writes.

Do offline changes persist after device restarts?

The offline persistence is also called disk persistence. This type of persistence is enabled by default in Cloud Firestore and it means that recently listened data (as well as any pending writes from the app to the database) are persisted to disk. The data in this cache survives app restarts and device reboots.

Does query performance of offline data degrade as the data set gets larger?

Yes it does, like explained above.

Do all the language clients implement the above in the same manner?

No. For iOS and Android, the offline feature works fine while for web, this feature is still experimental.

like image 116
Alex Mamo Avatar answered Oct 31 '22 12:10

Alex Mamo