Problematic Firestore Offline Persistence

Are you a laggard?

I’m in the process of developing an app that uses Firestore. This real-time database is still in beta version and in fact, it’s not so popular yet. It’s risky. There isn’t enough documentation and it lacks high quality tutorials and beaten paths. But there are thousands of early adopters that decided to use it.

Firestore Has Issues

There are a lot of comments about high latency, cold start, expensive scaling. Numerous articles show Firestore as a good choice for demo applications but not the best choice for serious projects. It’s still a beta version. But people say that it’s too much for beta version. That means it has some serious bugs and performance issues. One of them hit me hard.

Slow Offline Persistence

Firestore provides offline persistence. It’s enabled by default and really easy to turn off. In fact, many users recommended to disable it due to huge latency. In my case, Firestore stored everything offline in an app. Truly every item from a given collection. It slowed down an app severely. I figured out that clearing app data helps but it wasn’t the way to go. The point is we shouldn’t save redundant data.

Select Source of Data

Fortunately, you can fix it by picking the collection’s data source. For example, if you don’t want to store collection offline, just set the source to “server”. Do you want to rely on offline copies? Pick “cache”. If you want Firestore to pick the best for you, use “default”. In my case selecting “server” worked but there was one problem. Firestore was…

Still Too Slow

After selecting source of data, the app gained some speed. It got better, from up to 30seconds (sick) for loading first 10items from a 1000item collection to 3-10 seconds after picking “server” as a source. Still too slow. Although smaller collections had almost no latency and I didn’t see any cold start.

Conclusion

I would use Firestore 16.0.1 for a small Android app that isn’t offline first and doesn’t heavily rely on offline support. I wouldn’t implement it in bigger projects though. Maybe just set a reminder to check out Firestore in 6 months.

And one more thing

It’s very comfortable database but as a passenger you don’t hold the steering wheel. You may want to try Firestore and then migrate data somewhere else. It seems that Firestore doesn’t support it for now. Maybe in the future? Firebase has this feature so that’s highly possible.