Nginx 背后的瘦“连接到上游时没有实时上游”

发布于 2024-09-14 19:57:09 字数 285 浏览 1 评论 0原文

我可能在 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 技术交流群。

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

发布评论

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

评论(1

打小就很酷 2024-09-21 19:57:09

caches_action 加上操作内的redirect_to 导致了这种情况。看起来它正在写入缓存(或可能从中读取),然后重定向,这导致连接过早关闭。我可以通过使用caches_action 中的if 条件来检测是否会发生重定向来解决这个问题。如果我检测到它会发生,我会在 x.cacheable 中返回 false?

my_controller.rb

caches_action :show, :if => Proc.new { |x| x.cacheable? }

action_controller.rb

def cacheable?
  params[:id]>1000 ? true : false
end

基本上,如果 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

caches_action :show, :if => Proc.new { |x| x.cacheable? }

action_controller.rb

def cacheable?
  params[:id]>1000 ? true : false
end

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.

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