在New Relic上,对Heroku Rails应用程序的“花在Ruby中的时间”有何贡献?

乔尔

我正在尝试改善Heroku上托管的beta版Rails 3.2应用程序的性能。

积极的缓存已大大改善了性能,但是当我在New Relic上查看应用程序服务器响应时间时(在图上为浅蓝色),我仍然注意到“在Ruby中花费的时间”做出了很大的贡献。

Rails应用程序的哪些部分通常会促成这个“ Ruby时间”?

红宝石上花费的新遗物时间

最初,我认为这是由于我的一个主控制器中的条件复杂,但已对此进行了简化。现在,使用Russian Doll片段缓存和memcache可以非常积极地缓存我的视图(哇!)。

可以动用静态资产吗?(移至S3 / CloudFont在待办事项列表上...)

谢谢!

(我已经设置了delay_job设置,并将所有可能的操作移到了后台。我也正在使用Unicorn作为我的Web服务器。)

更新的性能调整

经过积极的缓存之后,我开始寻找其他方法来提高应用程序性能。

首先,我根据建议添加了垃圾回收监控,发现GC对Ruby时间的贡献不大。

在此处输入图片说明

接下来,我决定通过添加CDN(通过CDNsumo插件在Cloudfront中)来实现我的资产服务。有趣的是,这确实减少了我在NR监视上的Ruby时间。(已预配置CDN,然后通过下图最右边的最后一个请求测试进行预热。)我的大多数页面都有数百kb的CSS和javascript-很小但不是很大。

在此处输入图片说明

Finally, I upgraded from the 'Basic' starter database to the smallest production db 'Crane'. This had a dramatic effect on performance. After a little caching by PG the app flies. (final 3 request spikes on the graph below).

在此处输入图片说明

Take home messages for others trying to tune their Heroku apps:

  • Simple performance tuning in multiple areas (ie. caching, CDN, database, Ruby code) has a synergistic effect across the stack.
  • Conversely, any single performance drain will be a bottleneck that you cannot overcome even if you tune the other areas (ie. the slow starter Basic or Dev databases on Heroku versus an 'expensive' production database - the slow Basic db was killing my app performance).
  • NewRelic is essential in working out where the most gains can be made.
Winfield

"Ruby" time is really the "Other" bucket for NewRelic tracing. The other categories are explicit measures (ie: how much time is spent in calls out to memcached). Ruby time is all of the time not spent in one of those buckets.

So what other things happen in "Ruby" time? The number one candidate is Garbage Collection (GC). If you're running Ruby 1.9+, you can enable NewRelic profiling of GC by creating an initializer like config/initializers/newrelic.rb with the following:

GC::Profiler.enable

This will track GC time as a separate NewRelic category for you.

If you're in good shape on GC, the next step is to use the Web Transactions view to see how these average times are distributed. Perhaps one or two actions in your application are horrible performers and responsible for these averages.

祝您好运,如果您仍然遇到问题,请随时直接与我们联系。性能调整是一门妖术。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在New Relic上添加新的Rails红宝石应用程序?

无法检测到New Relic仪器。Android应用程序中的错误

如何在New Relic上启用PHP代理?

Cloud9 中的 Ruby on Rails 应用程序在 Heroku 上“不存在”

使用Gunicorn作为流程管理器将New Relic与Tornado应用程序集成

New Relic 监控的应用程序能否从其内部显式生成事件警报?

推送到heroku时,Ruby on Rails应用程序不断崩溃,日志中没有信息

使用New Relic和Heroku进行服务器资源监视

如何调整在使用生产级别Heroku Postgres的Heroku上运行的Ruby on Rails应用程序?

是否可以使用New Relic监视Azure Function应用?

如何从New Relic api中读取部署事件?

如何在 New Relic 中查看完整查询

无法在Heroku上运行的Ruby on Rails 4.1.4应用程序中为生产环境设置secret_key_base

在哪里可以找到用于AWS Lambda的New Relic上的CPU和内存利用率?

Elastic Beanstalk上New Relic的nrsysmond的唯一主机名

Intellij Idea 14.1.2上的New-> Web应用程序没有选项

“元素无法点击” New Relic

无法在 Heroku 上启动全新的 Rails 应用程序

Heroku:在同一实例上运行带有Python脚本的Rails应用程序

如何将heroku上的现有Web应用程序迁移到Rails?

在Heroku上使用MailGun for Rails应用程序中的红宝石

在Heroku上,如何部署不在git repo根目录中的Rails应用程序?

Heroku上新的Rails 5.2.1应用程序中的Javascript无法正常运行

Ruby on Rails应用未部署在Heroku上

Heroku 上的 MERN 应用程序

在 Heroku 上反应应用程序

无法看到在Heroku上部署Ruby on Rails应用程序?

Heroku 拒绝来自 Ruby on Rails 应用程序的推送

在RVM / ruby 2.1.0中使“ rails new”适用于第二个应用程序