Firebase Android: slow “join” using many listeners, seems to contradict documentation

*爱你&永不变心* 提交于 2019-12-04 05:27:11

"This prompts the question whether having potentially many listeners will have a negative impact on performance or perhaps would hit some hard limit."

The answer is the same for Firebase Realtime database as it is for the new Cloud Firestore database.

I doesn't matter how many connections you have or how many listener you have, it matters how much data you are processing on the client side.

So if you have 100 listeners, listening to 100 bits of small data, that's gone a be pretty cheap but if each of those listeners is listening to a stream of constantly changing data, that's gone a get very expensive for the client to deal it very quickly.

And because mobile devices are very different is very difficult to know how many is too many. So if you targeting american users who tend to have very high-end phones, that's will be a different limit if we targeting countries with phones that are much lower powered.

So you can have as many listeners as you want, if you are removing them accordingly to the life-cycle of the activity, as exaplined here.

There is also another approach, to use a addListenerForSingleValueEvent. In thise case, there is no need to remove a listener.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!