modrails - 流氓 ruby 进程消耗 100% cpu
我的 mod_rails 中的 ruby 实例变得“流氓”——这些进程不再列在乘客状态中并使用 100% 的 cpu。
除了安装 god/monit 来杀死实例之外,任何人都可以给我一些关于如何防止这种情况的建议吗? 我在日志中找不到任何有帮助的内容。
I'm having ruby instances from mod_rails go "rogue" -- these processes are no longer listed in passenger-status and utilize 100% cpu.
Other than installing god/monit to kill the instance, can anyone give me some advice on how to prevent this? I haven't been able to find anything in the logs that helps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用的是 Linux,则可以安装“strace”实用程序来查看 Ruby 进程正在执行哪些操作,从而消耗了所有 CPU。 这将为您提供良好的低层视图。 它应该在您的包管理器中可用。 然后你可以:
然后,如果你想在中间停止进程并转储堆栈跟踪,你可以按照 http://eigenclass.org/hiki.rb?ruby+live+process+introspection,具体做的是:
你也可以使用 ruby-debug Gem远程连接到您打开的调试套接字,如 http://duckpunching 中所述.com/passenger-mod_rails-for-development-now-with-debugger
Github 上似乎还有一个与调试 Passenger 实例相关的项目,看起来很有趣,但缺乏文档:
http://github.com/ddollar/socket-debugger/tree/master
If you're using Linux, you can install the "strace" utility to see what the Ruby process is doing that's consuming all the CPU. That will give you a good low-level view. It should be available in your package manager. Then you can:
Then, if you want to stop the process in the middle and dump a stack trace, you can follow the guide on using GDB in Ruby at http://eigenclass.org/hiki.rb?ruby+live+process+introspection, specifically doing:
You can also use the ruby-debug Gem to remotely connect to debug sockets you open up, described in http://duckpunching.com/passenger-mod_rails-for-development-now-with-debugger
There also seems to be a project on Github concerned with debugging Passenger instances that looks interesting, but the documentation is lacking:
http://github.com/ddollar/socket-debugger/tree/master
我有一个与 Phusion Passenger 相关的 ruby 进程,它消耗了大量的 CPU,即使它应该是空闲的。
运行后,问题就消失了
在我按照此线程中的建议 。 (那是在 Debian Squeeze 上)
显然,该问题与闰秒有关,并且可能会影响许多其他应用程序,例如 MySQL、Java 等。更多信息请参见 lklm 上的这个帖子。
I had a ruby process related to Phusion Passenger, which consumed lots of CPU, even though it should have been idle.
The problem went away after I ran
as suggested in this thread. (That was on Debian Squeeze)
Apparently, the problem was related to a leap second, and could affect many other applications like MySQL, Java, etc. More info in this thread on lklm.
我们在长时间运行的 SQL 查询中看到了类似的情况。
MySQL 会终止查询,因为它们超出了长时间运行限制,并且线程从未意识到查询已终止。
您可能想检查数据库日志。
We saw something similar to this with very long running SQL queries.
MySQL would kill the queries because they exceeded the long running limit and the thread never realized that the query was dead.
You may want to check the database logs.
这是乘客经常遇到的问题。 我已经多次看到这个问题,帮助人们在 Rails 上运行 ruby 和乘客。 我没有解决办法,但您可能想尝试一下 http: //www.modrails.com/documentation/Users%20guide%20Apache.html#debugging_frozen
This is a recurring issue with passenger. I've seen this problem many times helping people that ran ruby on rails with passenger. I don't have a fix but you might want to try this http://www.modrails.com/documentation/Users%20guide%20Apache.html#debugging_frozen