我在日志中看到很多异常:
A Mongo::OperationFailure occurred in foo#bar:
Mongo::OperationFailure
mongo (1.6.2) lib/mongo/util/tcp_socket.rb:76:in `read'
我使用Mongoid作为我的Ruby驱动程序。
不确定这是否与连接池相关,但只是在事件发生时,这是我的mongoid.yml:
production:
host: xxx
port: 27017
username: xxx
password: xxx
database: foo
logger: false
pool_size: 200
max_retries_on_connection_failure: 5
我理解EC2可能会出现短暂的网络问题,但这几乎已成为常态。解决这个问题的最佳方法是什么?
仅仅是为了获取背景信息,我正在运行JRuby 1.6.7。
答案 0 :(得分:0)
m1.large
。TCP keepalive
超时设置为300 seconds?top
和mongostat
检查了数据库服务器上的基本统计信息?如果您使用过某些监控工具,他们告诉您了什么?如果你还没有,那就使用它们并报告你找到的东西。
答案 1 :(得分:0)
这可能与
相关# Connect nonblock is broken in current versions of JRuby
connect
中的lib/mongo/util/tcp_socket.rb
:link to file
def connect
# Connect nonblock is broken in current versions of JRuby
if RUBY_PLATFORM == 'java'
require 'timeout'
if @connect_timeout
Timeout::timeout(@connect_timeout, OperationTimeout) do
@socket.connect(@socket_address)
end
else
@socket.connect(@socket_address)
end
else
... # nonblocking connect
错误发生here:
rescue Errno::EINTR, Errno::EIO, IOError
raise OperationFailure
end
所以它可能是EIO/IOError
。
也许尝试使用Ruby而不是JRuby?
希望这有帮助。
(如果我必须做一个没有受过教育的猜测,我可能会后悔说,那就是因为JRuby必须使用阻塞套接字connect
而不是非阻塞套接字EIO/IOError
,read
期间{{1}}发生了大量读取/连接。)