如何在Rails应用程序的内存中剖析生产红宝石 [英] How to profile a production ruby on rails app's memory
问题描述
我的Ruby on Rails应用程序在Heroku上运行,具有512 MB内存的dyno。它几乎是从应用程序启动时使用的所有RAM,并且从那里只会变得更糟。我不在启动时从数据库加载大量数据,所以不明白为什么它使用了太多内存。
如何在生产环境中配置我的应用程序,以便我可以理解内存使用来自哪里?我知道我可以选择添加另一个dyno或增加dyno内存,但我想先了解发生了什么。 解决方案
Heroku具有 log-runtime-metrics
功能来监视内存使用情况。
您可以运行此命令启用:
heroku labs:启用log-runtime-metrics
以及内存使用情况将显示在服务器日志中。
请参阅 Heroku Labs:log-runtime-metrics 获取更多信息。
另外,您可以使用New Relic进行内存分析。
请参阅 documentation 获取更多详细信息。
我推荐的另一个很棒的资源内存分析是 rbkit
My Ruby on Rails app is running on Heroku, with a dyno that has 512 Megabytes of RAM. It is using almost all the RAM right from app startup, and it only gets worse from there. I am not loading large amounts of data from the database at startup so do not understand why it is using so much memory.
How do I profile my app in production so I can understand where the memory usage is coming from? I understand that I have the option of adding another dyno or increasing the dyno memory, but I want to understand what is happening first.
Heroku has a log-runtime-metrics
feature to monitor the memory usage.
You can run this to enable that:
heroku labs:enable log-runtime-metrics
and the memory usage will be shown on the server log.
See Heroku Labs: log-runtime-metrics for more information.
Also, you can use New Relic for the memory profiling.
See the documentation for more details.
Another awesome resource that I recommend for memory profiling is rbkit
这篇关于如何在Rails应用程序的内存中剖析生产红宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!