Android 澄清 Firebase 连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21070095/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Clarify the Firebase connections
提问by webduvet
I am a little confused about the Firebase pricing model, special concern is the connections or more precisely concurrent connections.
我对 Firebase 定价模型有些困惑,特别关注的是连接或更准确地说是并发连接。
Let's have an example of a mobile app for iOS called FanZONE:
让我们举一个名为 FanZONE 的 iOS 移动应用程序示例:
User will create groups during football matches. They will comment on the actual game and the comments are immediately displayed on each members screen.
用户将在足球比赛期间创建组。他们会对实际游戏发表评论,评论会立即显示在每个成员的屏幕上。
Does this scenario means that each user who is participating on commenting/viewing counts for one connection?
So if a group contains 100 users who actively follow the screen and from time to time comment is there 100 connections each 90 minutes long?
What about users who have the app in the background and the app checks each 5 minutes the score. Is this connection as well 90 minutes long or only a fraction of time every 5 minutes?
这种情况是否意味着参与评论/查看的每个用户都计为一个连接?
因此,如果一个群组包含 100 个积极关注屏幕并不时发表评论的用户,那么每 90 分钟是否有 100 个连接?
那些在后台运行应用程序并且应用程序每 5 分钟检查一次分数的用户呢?这种连接也是 90 分钟长还是每 5 分钟只有一小部分时间?
回答by Kato
In addition to Mike P's excellent answer, here are a few other discussions on the same topic which may prove insightful.
除了 Mike P 的出色回答之外,这里还有一些关于同一主题的其他讨论,这些讨论可能很有见地。
From the Firebase pricing page:
从 Firebase定价页面:
What is a Connection?
A connection is an open network connection to our servers. It's a measure of the number of users that are using your app or site simultaneously. This isn't the same as (and is usually a lot lower than) the total number of visitors to your site or the total number of users of your app. In our experience, 1 concurrent corresponds to roughly 1,400 monthly visits.
Our Development Firebase has a hard limit on the number of connections allowed. All of the paid Firebases, however, are “burstable”, which means usage is not capped and instead you are billed for any overages. We measure connections for paid plans based on the 95th percentile of usage during the month.
什么是连接?
连接是到我们服务器的开放网络连接。它衡量同时使用您的应用或网站的用户数量。这与您网站的访问者总数或应用程序的用户总数不同(并且通常远低于)。根据我们的经验,1 个并发对应于每月大约 1,400 次访问。
我们的开发 Firebase 对允许的连接数有硬性限制。但是,所有付费的 Firebase 都是“突发”的,这意味着使用量没有上限,您需要为任何超额付费。我们根据当月使用的第 95 个百分位来衡量付费计划的连接。
From this mailing list discussion, by Andrew Lee (Firebase founder):
来自这个邮件列表讨论,作者 Andrew Lee(Firebase 创始人):
I strongly recommend you not worry about it unless you're actually bumping up against our limits...most developers vastly overestimate the number of concurrent users they will have. A good rule of thumb is 1 concurrent = 1000 monthly visits for the typical website. For mobile, the ratio between installs and concurrents is sometimes even higher (though it varies considerably depending on your use case). Our plans are quite generous when it comes to concurrent users. As a data point -- our own website could operate comfortably on the "free" Firebase plan most days. In fact, more than 99.5% of all of Firebases never hit the 50 concurrent limit.
So, long story short, if you're working on a hobby project, you will almost certainly not hit our free tier 50-concurrent limit. If you're a business or a larger app, I hope you will find our $49 / month plan more cost-effective than spending engineering time to figure out when to goOnline / goOffline to minimize that number.
At the very high end (huge Enterprise apps with 10k+ concurrents) we do offer custom pricing that has a lower per-concurrent rate.
我强烈建议您不要担心,除非您确实遇到了我们的限制……大多数开发人员都大大高估了他们将拥有的并发用户数量。一个好的经验法则是,典型网站的 1 个并发 = 1000 次每月访问。对于移动设备,安装量和并发量之间的比率有时甚至更高(尽管它会因您的用例而有很大差异)。对于并发用户,我们的计划非常慷慨。作为一个数据点——我们自己的网站大部分时间都可以在“免费”的 Firebase 计划上轻松运行。事实上,超过 99.5% 的 Firebase 从未达到 50 个并发限制。
因此,长话短说,如果您正在从事业余爱好项目,您几乎肯定不会达到我们的免费 50 级并发限制。如果您是企业或大型应用程序,我希望您会发现我们 49 美元/月的计划比花费工程时间来确定何时上线/下线以最小化该数字更具成本效益。
在非常高端(具有 10k+ 并发的大型企业应用程序),我们确实提供具有较低每次并发费率的自定义定价。
A user benchmarking and testing of connections here on SO: How the Connection is calculated in Firebase
SO 上的用户基准测试和连接测试:如何在 Firebase 中计算连接
Another similar question here on SO: How are concurrent connections calculated
SO上的另一个类似问题:如何计算并发连接
回答by Mike Pugh
In your first scenario - the short answer is yes. As long as your users keep the screen on where you have a Firebase connection that allows them to comment/read comments - you will have one concurrent connection per screen.
在您的第一个场景中 - 简短的回答是肯定的。只要您的用户将屏幕保持在您拥有允许他们评论/阅读评论的 Firebase 连接的位置,您将在每个屏幕上拥有一个并发连接。
In your second scenario - this depends on how you develop your app. The Firebase API does provide you with the goOfflineand goOnlinemethods (https://www.firebase.com/docs/ios-api/Classes/Firebase.html#class_methods) which give you control over your connection. If you want to go offline for 5 minutes, then briefly come back online to check scores and then go offline again, then you'd only hold a connection for a short duration.
在您的第二种情况下 - 这取决于您如何开发您的应用程序。Firebase API 确实为您提供了goOffline和goOnline方法 ( https://www.firebase.com/docs/ios-api/Classes/Firebase.html#class_methods),让您可以控制您的连接。如果你想离线5分钟,然后短暂地回到在线查看分数,然后再次离线,那么你只能保持短暂的连接。
Concurrent connections are just that - connections established at the same time. So if you have 3 people using your app to check scores, but user 1's app goes online at 12:00 PM and the connection lasts for 5 seconds, then user 2's app goes online at 12:01 PM for 5 seconds, and user 3's app goes online at 12:02 PM for 5 seconds then you've only ever had 1 concurrent connection.
并发连接就是 - 同时建立的连接。因此,如果您有 3 个人使用您的应用查看分数,但是用户 1 的应用在下午 12:00 上线并且连接持续了 5 秒,那么用户 2 的应用在下午 12:01 上线了 5 秒,而用户 3 的应用应用程序在下午 12:02 上线 5 秒,那么您只有 1 个并发连接。
If on the other hand, all 3 users' apps go online at 12:00 PM for 5 seconds then you'll have 3 concurrent connections.
另一方面,如果所有 3 个用户的应用程序都在下午 12:00 上线 5 秒,那么您将有 3 个并发连接。
You could potentially use this same goOffline/goOnline strategy with your first scenario, but that may detract from the experience if your users are expecting to be chatting about a game in near real-time.
您可以在第一个场景中使用相同的 goOffline/goOnline 策略,但如果您的用户希望近乎实时地讨论游戏,这可能会影响体验。