gpt4 book ai didi

ruby-on-rails - 如何处理 rails/mongoid 中的出队连接超时?

转载 作者:IT老高 更新时间:2023-10-28 13:24:25 24 4
gpt4 key购买 nike

我的堆栈:RoR4.2.6,Mongoid 5.0.1

我正在使用 apache benchmark 对我的网站进行基准测试,并不断遇到如下错误:

2016-03-24 22:15:36 +0000 pid=23187, severity=FATAL, 
ActionView::Template::Error (Timed out attempting to dequeue connection after 1 sec.):
22: =link_to '/albums/' + mention.object.slug do
23: .small-12.medium-6.large-4.columns.left
24: .mention-box
25: %img.mention-thumb{src: mention.object.thumb_url}
26: %h5.mention-name
27: = mention.object.name
28: %br
app/models/mention.rb:13:in `object'
app/views/posts/_full_mention.html.haml:25:in `block in _app_views_posts__full_mention_html_haml___1744802549767261808_47000690052420'

仅供引用,这是在mention.rb中调用的行,只是一个简单的查找查询:

  def object
Object.const_get(type).find(mention_id)
end

我的假设是,这意味着我用太多请求访问 mongoDB,它无法跟上,但不完全确定如何解决这个问题。我应该为 mongoid 设置更高的队列超时吗?感谢任何建议!

最佳答案

遇到同样的问题,通过在 mongoid.yml 生产配置中添加 wait_queue_timeout 属性解决:

production:
clients:
default:
uri: mongodb://xxx.com:27017/mongo
options:
connect_timeout: 15
wait_queue_timeout: 15

关于ruby-on-rails - 如何处理 rails/mongoid 中的出队连接超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36211295/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com