Ruby on Rails 服务器长时间随机挂起/滞后

发布于 2024-09-09 23:22:16 字数 193 浏览 0 评论 0原文

我有一个程序可以让一个简单的 Ruby on Rails 服务器上线。服务器用于在同一网络上的计算机之间进行通信和整理数据。我没有对 Ruby 做任何花哨的事情。我只是使用脚手架生成了 3 个模型,仅此而已。问题是,过了一段时间(计算机和服务器之间的许多 HTTP 请求 ~= 10 分钟),服务器开始滞后并永远挂起,迫使我终止服务器脚本并重新启动它。有什么帮助/建议吗?

I have a program that makes a simple Ruby on Rails server go live. The server is used to communicate and collate data between computers on the same network. I have not done anything fancy to the Ruby stuff. I have simply used scaffold to generate 3 models and that is it. The problem is that after a while (many HTTP requests between the computers and the server ~= 10 minutes) the server starts to lag and just hangs forever, forcing me to kill the server script and restarting it. Any help/suggestions?

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

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

发布评论

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

评论(1

离不开的别离 2024-09-16 23:22:16

您是否在开发模式下运行或已关闭类缓存?

在开发模式下运行的系统开始遇到一些问题的情况并不罕见。当您正在工作时,这没什么大不了的,只需重新启动开发服务器即可,但一旦您拥有了一个可以工作的系统,这可能会非常烦人。

关键问题在 config/environments/development.rb 中:

# In the development environment your application's code is reloaded on
# every request.  This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.    

config.cache_classes = false

这不仅会减慢响应时间,而且随着时间的推移,可能会导致缓慢的内存泄漏和不可预测的行为。

Are you running in development mode or have the class caching turned off?

It is not uncommon to find systems running in development mode to start hitting some issues. Not such a big deal when you are working and can simply restart the dev server, but can be very annoying once you have a working system.

The key issue is in config/environments/development.rb:

# In the development environment your application's code is reloaded on
# every request.  This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.    

config.cache_classes = false

Not only does this slow down response time, but it can lead to slow memory leaks and unpredictable behaviour over time.

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