Can Firestore Scale - firebase

Can the new Firestore service scale?
I know it's in beta. I'm looking for some live examples of Firestore Scaling.
In terms of:
Number of database transactions.
Size of database.
Also - Does firebase have some auto scaling policy.
Can Firebase itself scales in terms of:
Number of users (using the OAuth)
Does anyone have some Firebase scaling example and could share.

firebaser here
The first line on the main documentation page for Cloud Firestore:
Use our flexible, scalable NoSQL cloud database to store and sync data for client- and server-side development.
A bit lower in key capabilities:
Designed to scale
Cloud Firestore brings you the best of Google Cloud Platform's powerful infrastructure: automatic multi-region data replication, strong consistency guarantees, atomic batch operations, and real transaction support. We've designed Cloud Firestore to handle the toughest database workloads from the world's biggest apps.
That tells you that the folks that created Cloud Firestore thinks that scalability is one of its key features. Give that these are the same folks that worked on many of Google Cloud Platform's features, I tend to believe them on that front. :-)
There were also some earlier questions that may be relevant:
What's the difference between Cloud Firestore and the Firebase Realtime Database?
Designed to Scale -- Cloud Firestore will be able to scale better than the Realtime Database. It's important to note that your queries scale to the size of your result set, not your data set. So searching will remain fast no matter how large your data set might become.
Queries scale with the size of your result set, not the size of your data set
Just keep in mind that Cloud Firestore is still in beta and will be slower (but scale better) than Firebase's realtime database:
Firestore slow performance issue on getting data

Related

Using Firebase Realtime Database node keys as document ID's in Cloud Firestore

I am in the process of migrating my Realtime Database to Cloud Firestore. Ideally, I need to keep the same Realtime Database node keys that have been generated using push() and use it as the document ID in Firestore, but is this safe to do so?
I have read information at https://firebase.google.com/docs/firestore/best-practices and I am still unsure whether this will be safe. I am aware that auto generated document IDs in Cloud Firestore are in a different format to those automatically generated in Realtime Database.
Am I likely to run into problems by using by using Realtime Database generated keys such as: -M_NHw525_IxMqiGPUvd as the document ID in Cloud Firestore?
I really appreciate any help, Thanks.
Firestore is sensitive to hot spots in its writing process, meaning that write throughput is best when the writes are randomly distributed across the address space. In other words: if the IDs of the documents being written, and the values that are being written to the indexes, are randomly distributed.
Firebase Realtime Database push IDs start with an encoded timestamp, so they are definitely not randomly distributed. They are (by design) largely sequential: subsequent calls to push() typically leads to keys that are next to each other. This is exactly what they were designed for in Realtime Database, but it doesn't meet the requirement of a random distribution that is needed for maximizing write throughput in Firestore.
Whether you'll run into problems when using existing push keys for your Firestore writes really depends on the implementation. For example, during a data migration you'll want to be ready to throttle the writes (sooner) when they're not randomly distributed. Hopefully the above helps you to know what to keep an eye out for when performing the data migration.

Which firebase database to use for chat applicatoin, Firestore or Realtime Database?

I'm building an app which uses Firestore for storing most data. The app has a chat functionality and I was considering using Realtime Database for that. What are the benefits of using Firebase Firestore vs Realtime Database for this chat functionality? If there is no difference, should I use Firestore for everything?
P.S. I have already read the firebase comparison of the two https://firebase.google.com/docs/database/rtdb-vs-firestore and I am still not sure which way to go about this.
FB RTDB was designed for a chat application but is not so great for more than simple querying. Firestore was developed to improve the querying requirements and is newer. Newer doesn't necessarily mean better, depends on the use case. Their pricing models are very different, so you need to understand how your use case will be charged.
You can use both of course. They can work well together but if a simple chat requirement is all you need, I would use RTDB.
PS. The unique keys generated in RTDB for each new record are automatically in chronological order, which relates back to it being designed for a chat app. There is a caveat though, the chat messages may still get out of order because the keys are generated on the device and if the device clocks are slightly out and messages are being exchanged rapidly then you may get a miss timing. The way round this is to write each record with a property of server time...and use that to sort the chat messages. Hope that helps your decision.
PPS. RTDB charges for data storage volumes and data download volumes. Firestore charges for storage and db reads and writes. There will be a lot of the latter in a chat app so I would recommend running some what-if scenarios in Excel.

Realtime Database vs Firestore [duplicate]

This question already has answers here:
What's the difference between Cloud Firestore and the Firebase Realtime Database?
(5 answers)
Closed 3 years ago.
I am building an app related to online bookings of Barbers in my city.I am planning to use Firebase to store my data and showing realtime updates. What will be the right option i.e. Realtime Database or Firestore. As much as I read, Firestore is great but it costs the developers according to number of queries and in my case query numbers will be much higher as I am planning to show realtime update to clients for their booking status.
And I am a naive in this area so suggest which one will be easy to learn.
It's up to you in the end, so I'll just name some main points:
Realtime Database is basically one giant JSON file, while Cloud Firestore is based on collections of documents.
Both offer realtime updating.
Cloud Firestore has better ways to filter and sort data.
Cloud Firestore has more advanced ways of writing and updating information.
Realtime Database is based on a single region, while Cloud Firestore can scale to multiple regions automatically.
They have different security options.
Realtime Database charges based on bandwidth and storage, but at a higher rate. As you mentioned in your question, Cloud Firestore charges based on operations on your database (read, write, etc.)
In the end, it all depends on how you want to work in your code. For example, do you want to work with one large JSON tree, or do you want to work with separate documents? Cloud Firestore is the newer of the two, but that doesn't necessarily mean it's better in your scenario.

Does Firestore in "Datastore mode" have any advantages "Native mode"

Google Cloud Firestore is going to replace the legacy Google Cloud Datastore soon. One then has the choice between using Cloud Firestore in "native mode" or in "datastore mode". The former allows access to Firestore through the usual Firestore SDK while the latter allows usage of the old Cloud Datastore SDK (which has no Web/Mobile APIs).
I am not yet familiar with Firestore. My question is: Apart from porting things to a new API, are there actually any things that can not be done with Firestore in "native mode" which could be done with the old Cloud Datastore (or its replacement: Firestore in "datastore mode")? Or any other advantage of using "datastore mode" (like costs, for example)?
If not, then it seems there is actually no advantage of using Firestore in "datastore mode" other than compatibility for older code using the old Cloud Datastore.
Am I right in my assumption that Firestore "datastore mode" has absolutely no advantage besides being able to use the legacy Datastore API (at the cost of not being able to use the newer and probably more feature-rich Firestore APIs, including mobile and web APIs)?
Cost.
Firestore in Datastore mode supports key-only and projection queries just like the original datastore. That means that the result set of those queries counts towards "Cloud Firestore Small Operations" which are free.
We accumulate billions of those small operations per day and not having projection queries would effectively 10-fold our datastore cost which would be unbearable.
As this feature is not available in Firestore native mode - and also with the strong consistency added in - we expected it to be less performant then in the original datastore, but in our tests this was not the case. Firestore in datastore mode consistently performed about twice as fast for our application across all types of operations.
There are advantages of using "datastore mode", even for a new project.
I am evaluating the two modes of firestore "Datastore mode" and "Native mode" for a migration project from MySQL.
On one hand, I consider using the "Datastore mode" for one back-end global repository because:
Server side only
Strong performance expectation on search queries across all entities
Query and sort on several properties altogether
Structured data model with one root kind and few second level kinds
A lot of write with limited transaction requirement, a huge number of read with projection within an entity group
On the other hand, the "Native mode" seems to fit some requirements for a user facing specific application because:
Web, iOS, Android, API interface with bi-directional sync
Several occasionally connected use cases
Few large polymorphic objects to sync and to persist
Mostly simple query on one properties (parent object)
Though, there is one reason which advocate for Datastore mode for the second project
Multi-tenancy with namespace
There are also common needs fulfilled by both mode, which support the decision to migration to NoSQL technologies
Scalability
No admin
Availability
Speed of development
The items 2 to 5 and 10 are based on features specific for the Datastore Mode, not possible in Native Mode. The items 6 to 9 are specific to Native Mode.
Update : March, 21st 2019
Six months after the evaluation described in my first answer, my team is using both Firestore (native) mode and Datastore mode.
2 projects based on Firestore. We are using a lot the concepts of collection, sub-collection and documents and the undelying segregation of data.
We also have implemented listeners in iOS and Android apps for sub-collections selected accordung to strong business and security rules, which is not possible with Datastore.
9 projects based on Datastore. For three 3 of them, we are are using a lot the concepts of namespace and kind. We also use the global indexing of kind's properties and the projection of properties server-side, which is not possible with Firestore.
PS: we are considering to open-source our python library for fast development of a common API running either on Firestore and on Datastore.
According to official documentation, although Cloud Firestore is backwards compatible with Cloud Datastore, the new data model, real-time updates, and mobile and web client library features are not.
Cloud Firestore in Datastore mode uses Cloud Datastore system behavior but accesses Cloud Firestore's storage layer, removing the following Cloud Datastore limitations:
Eventual consistency, all Cloud Datastore queries become strongly
consistent.
Transactions are no longer limited to 25 entity groups.
Writes to an entity group are no longer limited to 1 per second.
Datastore mode disables Cloud Firestore features that are not compatible with Cloud Datastore:
The project will accept Cloud Datastore API requests and deny Cloud Firestore API requests.
The project will use Cloud Datastore indexes instead of Cloud Firestore indexes.
You can use Cloud Datastore client libraries with this project but not Cloud Firestore client libraries.
Cloud Firestore real-time capabilities will not be available.
In the GCP console, the database will use the Cloud Datastore viewer.
Because Firestore in Datastore mode is optimized for server use cases and for App Engine, we recommend using Firestore in Datastore mode for databases that will be used primarily by App Engine apps. Firestore in Native mode is most useful for mobile and real-time notification use cases.
https://cloud.google.com/appengine/docs/flexible/go/using-cloud-datastore
When looking further into the docs after reading this post, I came across this official GCP page. It explains in plain English that Firestore "Datastore mode" recommended for primarily server-side use cases.
This answers my question perfectly, because my use case is only server-side. Note: I don't have any first hand experience with Firestore yet, but I appreciate the answers that do.

Google Firestore a subset or superset of Google Cloud Datastore?

Google announced Firestore, the new document datastore on the block.
I have been developing an application using Google Cloud Datastore for over six months now and after reading the blog, I feel Firestore seems to be a better choice.
The concept of the alternate collection-document-subcollection looks excellent to me because while designing schema for datastore I was aware I will be unable to query nested fields. Now with firestore subcollections, I get full query capabilities which is a game changer for me (I can get maximum data with minimum queries).
As a counter argument, the flowchart suggests me to use datastore because I do not have any mobile clients.
Will it be a good idea to use Firestore just like Datastore ?
(I will conveniently ignore the mobile client/realtime updates/syncing features!)
Update 2 (01/31/19)
As of today, Cloud Firestore is no longer in Beta and is Generally Available:
https://cloud.google.com/blog/products/databases/announcing-cloud-firestore-general-availability-and-updates
This means that Cloud Datastore is no longer an option for new projects (you can keep using it on existing projects). New projects that want to use the Datastore API can use Cloud Firestore in Datastore mode.
Update 1
As you we have noticed, we've expanded Cloud Firestore since this question was posted.
This means Cloud Firestore now has 2 modes:
The original launch was 'Native mode'
The new launch adds 'Datastore mode'
'Datastore mode' is the 3rd gen of Cloud Datastore. 1st was called Master/Slave Datastore, 2nd was High-Replication Datastore (HRD) that was rebranded as Cloud Datastore in 2013.
The below answer is still largely relevant since both modes are currently mutually exclusive, so you need to pick one or the other.
The main differences are the improves of Cloud Firestore in Datastore mode over Cloud Datastore. The biggest ones are:
Write through-put per entity group now unbounded (was 1 write/second)
Transactions no longer limited to 25 entity groups
All queries now strongly consistent.
Also note Cloud Firestore regardless of mode is beta, so the new Service-Level Agreement (SLA) doesn't go into effect until the product reaches General Availability (GA).
Original Answer
Cloud Datastore (CD) and Cloud Firestore (CF) are similar, however different in significant ways.
CF is mobile-centric with direct from mobile client functionality with the Firebase SDKs and Rules functionality. CD is server-centric with a wider range of server client libraries, as well as some mature frameworks on App Engine Standard that bundle in memcache functionality.
CF has a newer storage layer that is strongly consistency in the same way as Cloud Spanner, however, it's still in beta without an SLA. CD's storage layer is only strongly consistent within entity-groups and eventually consistent across entity-groups, however, it is GA with a 99.95% SLA for the Multi-Region locations.
CF is only available in the US Multi-Region at this time. CD is available Cloud across a dozen locations including places in the Americas, Europe, Asia, and Australia.
CF during beta has a guideline limit of 2500 writes/second while we build experience monitoring and tuning the system prior to GA, whereas CD will happily handle >1M writes/second (please reach out to your account rep first though).
CF and CD's set of query capabilities are overlapping but not the same. Overall CD has a broader set of query capabilities we haven't built in CF yet, so you'd have more flexibility in CD.
Overall, I'd consider this list to see if any of the differences make or break what you're trying to build then pick the DB that fits closest to your needs.
Firestore is the 3rd generation architecture and replacement for Datastore, essentially available in 2 modes: Native mode and Datastore mode.
Documentation regarding the choices: https://cloud.google.com/datastore/docs/firestore-or-datastore
Video overview: https://www.youtube.com/watch?v=SYG-BgXoJFQ
I'd say that Datastore is now a subset of Firestore:
Cloud Firestore is the next major version of Cloud Datastore and a re-branding of the product.
See Choosing between Cloud Firestore and Cloud Datastore
Cloud Firestore can operate in "Datastore mode", making it backwards- compatible with Cloud Datastore. Some time after Cloud Firestore is released for general availability, Google will begin contacting owners of existing Cloud Datastore databases to schedule an automatic upgrade to Cloud Firestore in Datastore mode. See auto upgrade
Google documentation says:
Firestore is the new version of Datastore and removes several
Datastore limitations.
I think cloud firestore also has nodejs client and its not centric to mobile. Actually thats the difference between Firebase realtime database which was mobile-centri vs Cloud Firestore which is anything centric.

Resources