Firebase并发读/写请求限制 [英] Firebase concurrent read/write requests limits

查看:181
本文介绍了Firebase并发读/写请求限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

firebase支持多少个并发的读写请求。它可以支持50k的写入和50k的读取并发请求。在这个负载下读取和写入的平均响应时间是多少?假设数据大小不是很大,比方说只有50k个记录,每个请求将只读取或写入单个记录。

解决方案

在一定的时间间隔内有多少数据可写入磁盘是有物理限制的(在你的问题中你没有提及任何时间间隔)。 Firebase的限制是基于物理限制与逻辑相结合来保持共享服务对每个人的响应。这些数字会定期变化,所以我们不会透露它们。

一旦达到极限,写入就会轮流排队和处理。所以写吞吐量的任何峰值将被缓冲。您可以通过使用完成侦听器来检测您的写入正在被缓冲的时间。对于缓冲写入,您会看到在调用 set()和完成侦听器触发之间的时间增加。



对于这个特定的情况,我建议设置一个小的jsbin并且简单地测试它。写一个50k节点的循环应该很简单:

  var ref = firebase.database()。ref(); 
for(var i = 0; i <50000; i ++){
ref.child(i).set(true).then(function(ref){
// this当写完成
});



$ b $ p
$ b

你可能想在这里添加一些性能测量逻辑, a href =https://developer.mozilla.org/en-US/docs/Web/API/Performance/now =nofollow noreferrer> performance.now()


How many concurrent read and write request can firebase support. Can it support 50k write and 50k read concurrent requests. What will be the average response time for both read and write at this load. Assume that the data size is not huge, say only 50k records are there and each request will be reading or writing single record only.

解决方案

There is a physical limit to how much data can be written to a disk in a certain time interval (you fail to mention any time interval in your question). Firebase's limits are based on the physical limits combined with logic to keep the shared service responsive for everyone. These numbers change regularly, so we don't disclose them.

Once you reach the limit, writes will be queued and processed in turn. So any peak in write throughput will be buffered. You can detect when your writes are being buffered by using a completion listener. For buffered writes you'll see an increase in the time between when you call set() and when the completion listener fires.

For this specific case, I'd recommend setting up a small jsbin and simply testing it. A loop that writes 50k nodes should be simple enough:

var ref = firebase.database().ref();
for (var i=0; i < 50000; i++) {
    ref.child(i).set(true).then(function(ref) {
        // this is when the write has completed
    });
}

You'll want to add some performance measurement logic in there, probably using performance.now().

这篇关于Firebase并发读/写请求限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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