Apache和Resin组合时间歇性出现503错误的解决方法

原文出处:  Apache和Resin组合时间歇性出现503错误的解决方法
作者: Jet Mah from  Java堂
声明:  可以非商业性任意转载, 转载时请务必以超链接形式标明文章原始出处、作者信息及此声明!

 

使用Apache和Resin进行组合时,如果Resin关闭或中断的时会出现如下的HTTP 503错误:

Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

造成这个错误的原因是因为Resin无法启动,可以单独访问resin(如8080端口)查看具体的错误。

我这里要说的是,在Resin和Apache都非常非常正常的情况下,间歇性的出现上述错误,也就是说不是一直有,而是偶尔出现这个错误,刷新下页面就好了。这个问题非常郁闷,后来在resin的bug报告中(见参考资料)竟然发现了解决的办法:

The important configuration are load-balance-socket-timeout, socket-timeout, load-balance-idle-time and keepalive-timeout. The two load-balance-* configure mod_caucho. socket-timeout and keepalive-timeout configure the Resin side.

load-balance-socket-timeout needs to be large enough to handle any server-side processing delays before the first data.

socket-timeout and keepalive-timeout need to be larger than load-balance-idle-time because they need to keep the connection open for a keepalive request.

For a diagram, see

http://caucho.com/resin/admin/load-balancing.xtp

 

也就是说,Resin在同Apache进行组合通讯的时候主要依靠四个参数:load-balance-socket-timeout, socket-timeout, load-balance-idle-time 和 keepalive-timeout,其中两个load-balance-*参数用来设置mod_caucho(就是与Apache组合的so文件),socket-timeout和keepalive-timeout用来设置Resin。至于参数数值的大小顺序依此是:load-balance-socket-timeout > socket-timeout 和 keepalive-timeout > load-balance-idle-time。上述四个参数的官方说明地址为:http://caucho.com/resin-3.1/doc/server-tags.xtp

 

那为什么会间歇性出现503错误呢?这个是因为resin默认的socket-timeout为65s,时间太短了,有些比较大的请求在这个时间之内还没有进行完。综合上面所说,参考的配置如下:

  1. <resin ...>
  2.     <cluster id="app-tier">
  3.         <server-default>
  4.             <socket-timeout>180s</socket-timeout>
  5.             <keepalive-max>3000</keepalive-max>
  6.             <keepalive-timeout>180s</keepalive-timeout>
  7.             <load-balance-idle-time>120s</load-balance-idle-time>
  8.         </server-default>
  9.     </cluster>
  10. </resin>

从此,这个世界清净了。

 

参考资料:
Apache 2.2.x + Resin 3.1.x: frequent 503 status error messages (Service Temporarily Unavailable)
0002862: Apache + Resin and 503 HTTP Error
resin apache问题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值