转载 2015年07月07日 13:22:13

Optimizing TCP/IP Networking for API Clients

All Essbase C-API based clients communicate with the Essbase server by means of a network layer. A request from a client C-API based application to Essbase involves opening a TCP/IP socket at the start of the request and closing it at the end of the request. A socket is a resource managed by the operating system, and there are a fixed number of such resources - the number of which is operating-system specific. When a socket is closed, it enters a dormant state, referred to as TIME_WAIT state, for a duration that is operating-system specific and configurable. At the end of that time period, the socket can be reaped by the operating system for reuse. Whether a call to open a socket succeeds or not is a function of how rapidly the operating system is able to reap the closed sockets for reuse.

Problems may occur in cases where an API client is designed to make and conclude so many connections, so rapidly, that the fixed number of available ports (about 64,000) is at or near exhaustion. Because the used ports are still resting in TIME_WAIT state, available ports cannot be harvested fast enough by the operating system, and the result is that connections are denied or the program runs sluggishly. If a deployment expects highly concurrent processing and these symptoms are occurring, we recommend decreasing the TIME_WAIT delay for the operating system. For example, a significant performance improvement can result from decreasing the delay from four minutes to 30 seconds.

This situation can be detected by running the command netstat on the command prompt. The output shows the number of sockets that are in TIME_WAIT state. The higher the number, the larger the probability that certain subsequent API requests will fail.

To get around this situation, consider reducing the TIME_WAIT value on your operating system.

On Windows, the TIME_WAIT value is found in the Windows registry.

On UNIX, system tools such as ndd (Solaris & HPUX), no (AIX), and echo (Linux) are used to manipulate kernel parameters.

To view and adjust the TIME_WAIT value on Solaris and HP-UX,

ndd -get /dev/tcp tcp_time_wait_interval     
ndd -set /dev/tcp tcp_time_wait_interval 30000

On AIX, the following command gives a value for all parameters:

/usr/sbin/no -a 

Issue the following command on AIX to set TCP_TIMEWAIT state to 30 seconds (but do not adjust it if is already below 30):

/usr/sbin/no -o tcp_timewait =2
/usr/sbin/no -o tcp_ephemeral_low = 32768
/usr/sbin/no -o    tcp_ephemeral_high = 65535

On Linux, issue the following command to set the timeout_timewait parameter to 30 seconds:

echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout




下面我们用最简单的一对一的客户服务器模型来重现编程中遇到的一些问题: 初学socket的时候在编写socket程序的时候会遇到很多莫名其妙的问题,比如说bind函数返回的常见错误是EADDRINUSE...


转自:http://www.cnblogs.com/jason-jiang/archive/2006/11/03/549337.html TCP TIME_WAIT状态 关键词: TIME_W...


TIME_WAIT状态原理 ---------------------------- 通信双方建立TCP连接后,主动关闭连接的一方就会进入TIME_WAIT状态。 客户端主动关闭连接...


/*************************************              版权声明*   本文为本人原创,本人拥有此文的版权。鉴于本人持续受益于开源软件社区,* 本人声明...
  • kaylc
  • kaylc
  • 2011-02-26 15:55
  • 705


【tcp_tw_recycle和tcp_timestamps】 参考官方文档(http://www.kernel.org/doc/Documentation/networking/ip-sysctl....

Apache Web Server性能测试中大量TIME_WAIT解决方法 及 Linux sysctl.conf 优化解决方案

Background: ADF-FR / RR   ST/PT 测试时调整的参数。 今天早上一上班,有同事就反映公司好几个网站都打不开,登陆数据库 服务器(windows),发...