Skip to content Skip to sidebar Skip to footer

What Is The Maximum Number Of Retries For Firebase Transaction Before Failing

I have a node under Firebase for different restaurants which contains a list of active and past visitors. This node is named listvisitors. Under the restaurant node, i want a count

Solution 1:

The Firebase client currently aborts the transaction if it hasn't succeeded after 25 tries.

Well before you see that level of contention it'd be wise to change to a different strategy. The common way to solve this problem is to not have each visitor update the common counter, but instead have each of them write a "I visited this" into the database with a push():

ref.child("visits").push().setValue(currentUser.getUid());

Then you can have a server-side process that pulls the visits off the list and that increments the counter. In a stable state that means that the list of visits is empty. At any moment the visits list only contains visits that haven't been counted yet.

The reason this will perform better is that the server-side process will not have any contention for updating the counter. So it doesn't really need to use a transaction. But even if it does use a transaction, it will "never" have to retry.

Solution 2:

Maybe Princig FAQ can help you... To the question: What is a "simultaneous database connection"? This is the answer they provide:

Firebase imposes hard limits on the number of simultaneous connections to your app's database. These limits are in place to protect both Firebase and our users from abuse. The Spark plan limit is 100 and cannot be raised. The Flame and Blaze plans currently have an initial limit of 10,000 simultaneous database connections.This limit isn't the same as the total number of users of your app, because your users don't all connect at once. We encourage you to monitor your peak simultaneous database connections and upgrade if needed. We're working to remove the initial 10,000 simultaneous-connections cap on the Flame and Blaze plans.

About the option to get the current number of children, there is a methodnumbChildren but it depending on your snapshot... Here are some users discussing about that.

Post a Comment for "What Is The Maximum Number Of Retries For Firebase Transaction Before Failing"