再次遭遇大量CLOSE_WAIT

今天下午线上的Jetty服务又停止响应了。不过与上次不同的是,日志里没有Too many open files的问题(看来ulimit设置管用了),看不出任何问题。于是用netstat检查网络连接,发现了大量CLOSE_WAIT状态的连接,而且都是连接到同一个IP地址。联想到程序里有调用外部网站服务的部分,检查这个IP,正是其中的一个服务。检查代码,发现开发人员使用Commons HttpClient时出了问题,居然忘记关闭连接了(method.releaseConnection();)!!后果就是对方关闭了连接,连接不断地变成CLOSE_WAIT状态,直到耗尽所有的网络资源,没法再建立连接了。

从这个教训看出,项目的研发管理真是没有到位啊!快速反复的需求、几乎可以忽略的设计、缺少代码走查、没有单元测试,怎能保证上线前发现这样的问题!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.
For more help see http://daringfireball.net/projects/markdown/syntax

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>