modrails - 流氓 ruby​​ 进程消耗 100% cpu

发布于 2024-07-14 06:59:27 字数 147 浏览 15 评论 0原文

我的 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 技术交流群。

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

发布评论

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

评论(4

沉鱼一梦 2024-07-21 06:59:27

如果您使用的是 Linux,则可以安装“strace”实用程序来查看 Ruby 进程正在执行哪些操作,从而消耗了所有 CPU。 这将为您提供良好的低层视图。 它应该在您的包管理器中可用。 然后你可以:

$ sudo strace -p 22710
Process 22710 attached - interrupt to quit
...lots of stuff...
(press Ctrl+C)

然后,如果你想在中间停止进程并转储堆栈跟踪,你可以按照 http://eigenclass.org/hiki.rb?ruby+live+process+introspection,具体做的是:

gdb --pid=(ruby process)
session-ruby
stdout_redirect
(in other terminal) tail -f /tmp/ruby_debug.(pid)
eval "caller"

你也可以使用 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:

$ sudo strace -p 22710
Process 22710 attached - interrupt to quit
...lots of stuff...
(press Ctrl+C)

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:

gdb --pid=(ruby process)
session-ruby
stdout_redirect
(in other terminal) tail -f /tmp/ruby_debug.(pid)
eval "caller"

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

惟欲睡 2024-07-21 06:59:27

我有一个与 Phusion Passenger 相关的 ruby​​ 进程,它消耗了大量的 CPU,即使它应该是空闲的。

运行后,问题就消失了

date -s "`date`"

在我按照此线程中的建议 。 (那是在 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

date -s "`date`"

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.

自演自醉 2024-07-21 06:59:27

我们在长时间运行的 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.

残龙傲雪 2024-07-21 06:59:27

这是乘客经常遇到的问题。 我已经多次看到这个问题,帮助人们在 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

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