我正在开发一个可能有大量用户同时聊天的聊天风格的应用程序。当我进入主屏幕时,我正在检索聊天室列表,然后将 SnapshotListener
添加到每个聊天室以实时收听消息。这可能呈指数级增长,我最终可能会在客户端同时激活数百甚至数千个 SnapshotListener
。
我的问题是,这会影响性能吗?我的意思是,关于 Firebase 库,当有那么多听众同时处于 Activity 状态时,它有任何类型的限制或性能问题吗?当然不是每个人都会同时聊天,所以即使有 1000 个开放的听众,也只有 5-10 个会同时聊天和发送回叫。
最佳答案
根据Best Practices section of the official Firestore documentation :
You should always try to keep the number of snapshot listeners per client under 100.
你还应该记住一些more generic limits and quotas比如:
The maximum concurrent connections for mobile/web clients per database = 1,000,000
关于android - Firestore 快照监听器。在影响性能之前我可以听多少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59318886/