Nginx 背后的瘦“连接到上游时没有实时上游”
我可能在 50-100 个请求中就有一个遇到此错误。我在 nginx 后面运行 10 个 Thin 实例,我认为我的负载不够高,无法最大化所有 10 个实例的使用量..并且我希望 nginx 会等待,即使所有实例都很忙(也许不是?) 。以前有其他人见过这个吗?我正在尝试找出一种调试它的好方法。
这是我的设置: Rackspace 云服务器 2GB 实例上的 CentOS 5.5 nginx 0.7.67 薄1.2.7 轨道3RC Ruby 1.9.2rc2
Nginx 和 10 个 Thin 实例在同一服务器上运行。
I am getting this error in maybe one out of 50-100 requests. I am running 10 Thin instances behind nginx and I don't think that my load is high enough to max out the usage in all 10 instances.. and I would expect nginx to wait even if all instances were busy (maybe not??). Has anyone else seen this before? I am trying to figure out a good way to debug it.
Here is my setup:
CentOS 5.5 on Rackspace Cloud Servers 2GB instance
nginx 0.7.67
Thin 1.2.7
Rails 3RC
Ruby 1.9.2rc2
Nginx and 10 Thin instances are running on the same server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
caches_action 加上操作内的redirect_to 导致了这种情况。看起来它正在写入缓存(或可能从中读取),然后重定向,这导致连接过早关闭。我可以通过使用caches_action 中的if 条件来检测是否会发生重定向来解决这个问题。如果我检测到它会发生,我会在 x.cacheable 中返回 false?
my_controller.rb
action_controller.rb
基本上,如果 params[:id]<1000,我需要重定向到另一个控制器,所以可缓存? def 检查这一点并告诉caches_action 在这种特殊情况下不要缓存。
caches_action plus a redirect_to inside the action was causing this. It appears that it was writing to the cache (or possibly reading from) and then redirecting which caused the connection to close prematurely. I was able to get around the issue by using the if condition in caches_action to detect whether the redirect was going to occur. If I detected that it was going to occur, I returned false in x.cacheable?
my_controller.rb
action_controller.rb
Basically, I needed to redirect_to another controller if params[:id]<1000, so the cacheable? def checks this and tells caches_action not to cache in this particular situation.