After deploying our Rails app (4.0.9, Ruby 2.1.2), we notice requests to our app get hang after a while , usually 1 day or so.

在部署我们的Rails应用程序(4.0.9,Ruby 2.1.2)之后,我们注意到我们的应用程序的请求会在一段时间后挂起,通常是1天左右。

Using the gem rack_timer, we're able to find out requests got stuck at ActiveRecord::QueryCache middleware.

使用gem rack_timer,我们能够找到被困在ActiveRecord :: QueryCache中间件的请求。

Rack Timer (incoming) -- ActiveRecord::QueryCache: 925626.7731189728 ms

After removing it, our app seems to be back to normal. However, I understand the purpose of this middleware is to increase the performance, so removing is just a temporary solution. We're using mysql (5.1.67) with adapter mysql2 (0.3.13)

删除后,我们的应用程序似乎恢复正常。但是,我理解这个中间件的目的是提高性能,因此删除只是一个临时解决方案。我们使用mysql(5.1.67)和适配器mysql2(0.3.13)

Update: Right after I posted this question, the server started hang again, this time requests were stuck at ActionDispatch::Routing::RouteSet

更新:发布此问题后,服务器再次开始挂起,这次请求被卡在ActionDispatch :: Routing :: RouteSet

I, [2014-10-13T23:17:03.661346 #32498]  INFO -- : Rack Timer (Application Action) -- ActionDispatch::Routing::RouteSet: 3667661.2360477448 ms
I, [2014-10-13T23:17:03.661946 #32498]  INFO -- : Rack Timer (Application Action) -- ActionDispatch::Routing::RouteSet: 4373914.719343185 ms

Do you know any reason could cause this?

你知道任何理由可能导致这种情况吗?

Thank you in advance.

先谢谢你。

1 个解决方案

#1


1

The most possible cause is your connection with the database died (firewall, server configuration...) and Rails didn't notice, so a timeout happens inside ActiveRecord::QueryCache. Once Rails notices the connection died, it reconnects and the execution flow continues.

最可能的原因是您与数据库的连接中断(防火墙,服务器配置...)并且Rails没有注意到,因此在ActiveRecord :: QueryCache中发生超时。一旦Rails注意到连接中断,它就会重新连接并继续执行流程。

Try setting the param read_timeout in your database.yml file to something like 10 seconds and check your connection and server settings.

尝试将database.yml文件中的param read_timeout设置为10秒钟,然后检查连接和服务器设置。

更多相关文章

  1. 如何在产品和类别应用程序树中将1个表连接到(2个不同的表作为一个
  2. 求问vs窗体应用程序用gridview连接mysql未能获取数据库对象的列
  3. Android应用程序与外部数据库之间的安全性
  4. 制作一个基本的angularjs应用程序对我不起作用,我也不知道为什么
  5. Emberjs应用程序加载除Index之外的所有路由
  6. 在Android上使用离子崩溃而不是ios构建的混合应用程序
  7. 没有'Access-Control-Allow-Origin'反应表达docker应用程序
  8. 如何测试从实时网站提取数据的AJAX应用程序?
  9. 如何在单击按钮时将桌面应用程序导航到系统中设置的默认邮件提供

随机推荐

  1. PHP面向对象简易验证码类
  2. php反射机制用法详解
  3. 通过实例详细讲解PHP垃圾回收机制
  4. php对象转数组的函数
  5. 正则表达式详细基础实例解析
  6. 详细介绍php迭代器的作用
  7. php日期格式化方法详解
  8. PHP实现文件上传下载实例详细讲解
  9. php排序函数详细讲解(附实例)
  10. PHP魔术常量、魔术函数、预定义常量详细