廉价的Firebase听众 [英] Inexpensive firebase listeners

查看:98
本文介绍了廉价的Firebase听众的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇知道什么是Firebase侦听器的内部实现?



我听说过Firebase工程师说Firebase侦听器使用起来并不昂贵,可以用作非常需要。虽然我同意他们使应用程序实时。如果我在我的应用程序中有一堆的firebase监听器(为多个用户提供实时象棋应用程序),会发生什么情况。

监听器正在监听一系列的动作,玩家在游戏中或新游戏开始时移动。如果我有成千上万的用户每天同时使用应用程序,那么容易想象。

firebase是如何处理服务器上的这么多请求的,因为它们已经将侦听器的功能赋予了最终用户。

我们可以在我们的firebase应用程序中拥有尽可能多的侦听器。这是如何便宜?



如果我错误的内在假设,请纠正我的错误。

解决方案

< Firebase使用WebSockets,它是与服务器的持久连接。这意味着您不必担心发出请求,因为唯一获取的HTTP请求就是在开始建立套接字的时候。 这里是关于Web套接字的更多信息,它是与HTTP不同的协议。所以在你的情况下,为数据做许多单独的请求是完全可行的,因为没有真正的开销要考虑。设备的收音机已经打开,WebSocket头只有6个字节。

I am curious to know what is the internal implementation of firebase listeners like?

I have heard firebase engineers saying firebase listeners are inexpensive to use and can be used as much required. While I agree that they make the app real time. What happens if I have a bunch of firebase listeners in my app(a real time chess playing application for multiple users.)

The listeners are listening to bunch of actions including when a move is made by a player in a game or when a new game is started. Easy to imagine the scale if I have hundreds of thousands of users using the application concurrently everyday.

How does firebase handle so many requests on their server since they have given the power of listeners to the end user.

We can have as many listeners as we want in our firebase app. How is this inexpensive?

Please correct me if I am wrong in my inherent assumptions.

解决方案

Firebase uses WebSockets, which is a persistent connection to the server. This means that you don't have to worry about making a request, because the only HTTP request that gets made is in the very beginning to establish the socket. Here is more information about Web sockets which is a different protocol from HTTP. So in your case it's completely feasible to make many separate "requests" for the data, because there's no real overhead to consider. The device's radio is already on, and a WebSocket header is merely 6 bytes.

这篇关于廉价的Firebase听众的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆