Question

Firestore 1mb size limit

  • 19 September 2022
  • 5 replies
  • 125 views

Badge +1

Firstore has a 1mb size limit. RevenueCat’s firestore extension creates a single customer record which holds all the purchases the user makes. There is a potential for a user to make so many purchases over time it would exceed the 1mb limit of firestore documents. How does Revenuecat handle this situation?


5 replies

Userlevel 5
Badge +7

Hi @Brendan Rice , we do not currently explicitly handle that case. However, since the amount of data stored per subscription (it’s even less for one-off purchase) is less than 500 characters (not sure which encoding Firebase stores the data in), a customer could make north of 1000 purchases before they run into issues. 

Badge +1

The problem is our products are 1,5,10,15,30 coins which users can purchase over and over and over again and then we handle on our side the tracking of their total coin balance and the spending of coins. But because revenuecat tracks and retains every single purchase a user makes theoretically at some point a user will hit either the 1mb or 20k key index document limit.

It seems like for subscriptions revenuecat firestore integration is well suited but for non-subscription purchases that might occur at a high frequency there is a ticking time bomb waiting for revenuecat users.

If you could add some settings to purge old user purchase data past some configured cut-off date that would probably solve the issue. In our particular case we don’t really care what someone bought 1 year ago we only care about near real-time data say in the last 48hrs to be safe even that is older than is really necessary.

Userlevel 5
Badge +7

hmm I guess another way then could be to remove consumed purchases – would that help in your case? do you need the information about consumed purchases?

Badge +1

So we need information about consumed purchases but not long term. We just need the information long enough for us to ensure we processed it on our side correctly which should happen immediately in most cases but in the case of some sort of outage or error maybe would take a bit longer to recover from and so we would want to be able to go back and look at purchase history for llike the past week or something like that.

Our products in the apple/google stores are basically virtual coins and as soon as they buy them we credit their accounts in our own database tables at which point we don’t really need the purchase information anymore at least not in firebase where it can cause document sizing issues. We would clear the data out ourselves but as far as I can tell there is no way to tell revenuecat to delete info from a user record the only option is to completely delete a user which I assume would reset their purchase history but that seems like a pretty aggressive option.

Userlevel 5
Badge +7

Thanks for that explanation. I can’t promise a solution immediately but this helps come up with something that could help eventually

Reply