在一定的时间间隔内有多少数据可写入磁盘是有物理限制的(在你的问题中你没有提及任何时间间隔)。 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 =developer.mozilla/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并发读/写请求限制
发布评论