Table of Contents Previous Next
Logo
Connection Management : 37.4 Active Connection Management
Copyright © 2003-2009 ZeroC, Inc.

37.4 Active Connection Management

Active Connection Management (ACM) is enabled by default and helps to improve scalability and conserve application resources by closing idle connections.

37.4.1 Configuring ACM

ACM is configured separately for client (outgoing) and server (incoming) connections using the properties Ice.ACM.Client and Ice.ACM.Server, respectively. The default value of Ice.ACM.Client is 60, meaning an outgoing connection is closed if it has not been used for sixty seconds. The default value of Ice.ACM.Server is zero, which disables ACM for incoming connections. Ice disables server ACM by default because it can cause incoming oneway requests to be silently discarded, as discussed in Section 32.14.
The decision to close a connection is not based only on a lack of network activity. For example, a request may take longer to complete than the configured idle time. Therefore, ACM does not close a connection if there are outgoing or incoming requests pending on that connection, or if a batch request is being accumulated for that connection.
When it is safe to close the connection, it is done gracefully as described in Section 37.6. The closure is usually transparent to the client and server applications because the connection is reestablished automatically when necessary. We say connection closure is "usually transparent" because it is possible that the Ice run time will be unable to reestablish a connection for a variety of reasons (see Section 37.4.2). In such a situation, the application receives a local exception for new requests (usually a ConnectFailedException).
It is important that you choose an idle time that does not result in excessive connection closure and reestablishment. The default value of sixty seconds is a reasonable default, but your requirements may determine a more appropriate value.
The run time periodically scans through all open connections to close those that have exceeded their idle time. By default, the scanning interval is 10% of the smallest configured ACM timeout, with a minimum of 5 seconds and a maximum of 5 minutes. You can choose a different scanning interval by setting the property Ice.MonitorConnections to the desired interval in seconds. Once a connection exceeds its idle time, it is closed by the next scan. This means that, if you set a scanning interval of 120 seconds, and have an ACM timeout of 60 seconds, idle connections will be closed once they have been idle for between one and three minutes. For servers with many (thousands) of incoming connections, you should set the scanning interval to the longest amount of time you can afford connections to remain open past their idle limit; this reduces the overhead of the scans and makes it more likely that each scan will actually find and close idle connections.

37.4.2 Disabling ACM

Since server ACM is disabled by default, you only need to set Ice.ACM.Client to 0 to disable ACM for all connections. In this configuration a connection is not closed until its communicator is destroyed or it is closed explicitly by the application (see Section 37.5.4). It is important to note that disabling ACM in a process does not prevent a remote peer from closing a connection; all peers must be properly configured in order to truly disable ACM.
There are certain situations in which it is necessary to disable ACM. For example, oneway requests can be silently discarded when a connection is closed (see Section 32.14). As another example, ACM must be disabled when using bidirectional connections. A bidirectional connection is enabled by using a router such as Glacier2 (see Chapter 43) or by configuring a connection explicitly (see Section 37.7). If you do not disable ACM in such cases, ACM can prematurely close a bidirectional connection and thereby cause callbacks to fail unexpectedly.
Table of Contents Previous Next
Logo