如何调试性能问题/优化您的流星应用程序 [英] How to debug performance issue/optimize your meteor app

查看:39
本文介绍了如何调试性能问题/优化您的流星应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将 Meteor 应用程序部署到 Digital Ocean 上的生产服务器上.我注意到,对于大约 7500 个文档,完全获取对象(选择性地仅获取 3 个字段)并填充自动完成数据需要大约 3-5 秒.我相信对于如此多的数据应该是即时的,所以我很好奇如何从这里调试性能问题并优化更多.我应该如何调试 Meteor 应用程序的性能问题?我尝试查看网络选项卡,但似乎只需要一秒钟.我不知道为什么具有自动完成功能的搜索栏需要 3-5 秒才能准备好.仔细检查后,填充自动完成字段是即时的,直到 subscribe 函数的回调被调用的时间约为 3 到 5 秒.

I just deployed my Meteor app onto a production server on Digital Ocean. I noticed that for about 7500 documents, it takes about 3-5 seconds to fully fetch the objects (selectively taking only 3 fields) and populate the autocomplete data. I believe it should rather be instantenous for such number of data, so I am curious how I can debug performance issues from here and optimize more. How should I go about debugging performance issues for a Meteor app? I tried seeing the network tab but nothing seems to take more than a second. I am not sure why it takes 3-5 seconds for the search bar with an autocomplete feature to get ready. After a close inspection, populating autocomplete fields is instantaneous, and the time until subscribe function's callback is called is about 3 to 5 seconds.

我已经研究过 Kadira,但它报告说一切都在几毫秒内完成,所以我很困惑.

I've already looked into Kadira, but it reported that everything was complete within milliseconds, so I am confused.

可能相关:Meteor 的订阅和同步很慢

毕竟 7800 个文档,2 个字段,3-5 秒合理吗?

After all, is 3-5 seconds for 7800 documents with 2 fields reasonable?

推荐答案

让我告诉你这里到底发生了什么.

Let me tell you what's really happening here.

Kadira 显示从服务器获取数据并将其排队到网络所花费的时间.因此,500 - 700 毫秒是合理的.

Kadira shows the time taken to fetch the data from the server and queue it to the network. So, 500 - 700 ms is reasonable for that.

所以,这个 3-5 毫秒的延迟就是网络延迟.这意味着通过网络向客户端发送数据所花费的时间.7500+个文档就算是DDP上的三个字段也完全没问题.

So, this 3-5 ms latency is the network latency. That means the time taken to send data to the client via the network. It's quite okay for 7500+ documents even with three fields over DDP.

所以,我的建议是在服务器上进行搜索并使用类似搜索源

So, my suggestion is to do the search on the server and use something like Search Source for that.

这样,您将获得客户端所需的唯一数据.从而减少延迟并节省应用的 CPU.

With that, you'll get the only data required to the client. Which reduce the latency and saves the CPU of your app.

这篇关于如何调试性能问题/优化您的流星应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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