My latest Android app with Kotlin, Owly, displays one fact a day on your screen. Simple. The way I designed it is, a job is scheduled to work at 13:00 local time every day and when the job is triggered, it’s making a call to Firebase database to retrieve a Fact object to the device.
It all worked very well in the first week. Zero crash rate. Zero complaints. In the second week, I started getting emails saying that
App doesn’t show a new fact. All I see is the old ones!
I’m using Crashlytics for automatic bug reporting but wasn’t getting any reports. Then I checked logs and realized despite of making the call to Firebase database, application was not receiving any data!
After narrowing the issue down that much, I finally figured out what was wrong: I had 700+ active users and they were all trying to get the data from server at the same time (13:00)! When I was scheduling the job, I just didn’t think about the simultaneous connection limit of Firebase – which was only 100 in the Spark(free) plan. Therefore all connection requests after the 100th one was being refused.
Well the easiest solution could be upgrading to Blaze plan which was allowing 100.000 concurrent connections (when you pay $25 per month). What I did though was to change the fact retrieving time for users, setting a random time between 11am and 3pm:
That worked pretty well and we don’t have any issues at the moment. As expected, database connection went back to the desired levels, around 20 at a time:
Hope you remember to check your backend limits when you’re up to something. Price you pay for not doing so maybe a lot more than couple of uninstalls I had!