无法弄清楚是什么导致了我的 Rails 应用程序的性能瓶颈

发布于 2024-12-22 05:12:42 字数 373 浏览 3 评论 0原文

根据我的 Heroku 日志,我的 Rails 应用程序平均处理请求的时间约为 1700 到 2500 毫秒(这是整个往返)。我使用 new relic 来分析我的应用程序,似乎大部分请求都没有花在我的数据库中,而是花在 New Relic 的“Web 事务”部分中。看起来“控制器”类别往往是请求中最慢的,其次是“数据库”类别中的“SQL - SELECT”段。

我不太确定是什么导致了我的控制器的性能瓶颈,我也不认为我可以在不支付高级版本的情况下更深入地研究新的遗迹。我最近向应用程序的外键添加了索引,尽管我认为这对数据库响应时间没有太大影响。

我知道这些信息不足以找出导致这些瓶颈的原因,但我什至不知道从哪里开始或提供什么信息。如果人们可以告诉我需要哪些信息来诊断这些问题,那么这对我会有帮助。

My rails app, according to my heroku logs, is serving requests on average of about 1700 to 2500 milliseconds (this is the entire roundtrip). I used new relic to profile my app, and it seems that the majority of the request is not spent in my database but rather in the "Web Transaction" section of New Relic. It seems like the "Controller" category tends to be the slowest among requests, followed by the "SQL - SELECT" segment in the "Database" category.

I'm not quite sure what could be causing my performance bottleneck in my controllers, nor do I think I can dive deeper into new relic without paying for the premium version. I recently added indexes to the foreign keys of my application, although I do not think this made much of a difference in terms of database response times.

I know this is not enough information to figure out what is causing these bottlenecks, but I do not even know where to start or what info to give. If people could tell me what info is needed to diagnose these issues, then that would be helpful to me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

剪不断理还乱 2024-12-29 05:12:42

New Relic for Ruby 包含免费的独立开发者模式。当在 RAILS_ENV=development 中运行时,New Relic gem 添加一条路线,向您显示每个请求的详细配置文件。点击应用程序几次后,转到 http://localhost:3000/newrelic

该配置文件包括每个 SQL 查询以及代码组件的时间。您可以使用自定义工具将大块代码分解为更小的片段(或单独的方法)分别计时。此功能很像您在付费专业版中获得的交易跟踪,一个主要区别是您不想在生产中运行免费开发模式。

(全面披露:我为 NR 工作。不过,没有多少人知道免费开发模式,所以我认为值得一提。)

您可以使用 head.js,它将异步并行加载你的 JS 文件。

New Relic for Ruby includes a free, standalone developer mode. When running in RAILS_ENV=development, the New Relic gem adds a route that will show you a detailed profile for each request. Go to http://localhost:3000/newrelic after you hit your app a few times.

The profile includes time for each SQL query, as well as for components of your code. You can use custom instrumentation to break down big chunks of code into smaller segments (or individual methods) that get timed separately. This feature is a lot like the transaction traces you get in the paid Pro version, one major difference being that you wouldn't want to run the free dev mode in production.

(Full disclosure: I work for NR. Not many people know about the free dev mode, though, so I thought it was worth mentioning.)

You could potentially make Javascript loading appear even faster with something like head.js, which will load your JS files asynchronously and in parallel.

无需解释 2024-12-29 05:12:42

看看这个幻灯片:

http://www.slideshare.net/drhenner /optimize-the-obvious-7636674

可能还不够,但它会遇到一些常见的错误。

深入挖掘一下这个视频:http://windycityrails.org/videos2011/#2

它更长,但提供了很多地方可以看。

另一方面。您使用 CDN 吗?

Take a look at this slide show:

http://www.slideshare.net/drhenner/optimize-the-obvious-7636674

Might not be enough but it goes through some common faults.

Digging a little deaper take a look at this video: http://windycityrails.org/videos2011/#2

It is longer but gives a lot of places to look.

On a different note. Do you use a CDN?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文