A thread, or a single sequential flow of control within a process, is also called a lightweight process that reduces overhead by sharing fundamental parts with other threads. Threads are lightweight so that there can be many of them present within a process.
The two major thread models supported by VisiBroker are the thread pool (also known as thread-per-request, or TPool) and thread-per-session (also known as thread-per-connection, or
TSession). Single-thread and main-thread models are not discussed in this document. The thread pool and thread-per-session models differ in these fundamental ways:
With the thread-per-session (TSession) policy, threading is driven by connections between the client and server processes. When your server selects the thread-per-session policy, a new thread is allocated each time a new client connects to a server. A thread is assigned to handle all the requests received from a particular client. Because of this, thread-per-session is also referred to as thread-per-connection. When the client disconnects from the server, the thread is destroyed. You may limit the maximum number of threads that can be allocated for client connections by setting the
vbroker.se.iiop_ts.scm.iiop_ts.manager.connectionMax property.
In the following scenario, a client application is bound to two objects in the server process. Each bind() shares a common connection to the server process, even though the
bind() is for a different object in the server process.
The name specified in the above property as the <srvr_eng_name> is the name of the ServerEngine. The SCMs listed here will be the list of SCMs for the associated server engine. SCMs cannot be shared between ServerEngines. However, ServerEngines can be shared by multiple POAs.
The host property is the IP address for the server engine to listen for messages.
The proxyHost property specifies the proxy IP address to send to the client in the case where the server does not want to publish its real hostname.
Each POA in a multi-threaded object server can choose between two dispatch models: thread-per-session or
thread pool. You choose a dispatch policy by setting the
dispatcher.type property of the
ServerEngine.
ThreadPool (thread pooling) is the default dispatch policy when you create a POA without specifying the
ServerEnginePolicy.
For ThreadPool, you can set the following properties:
sets the initial idle worker thread check interval to 120 seconds for the default TPool server engine. The default value of this property is 300 seconds. With this setting, the server engine will check the idle state of each worker thread every 120 seconds. If a worker thread has been idle across two consecutive checks, it will be recycled (terminated) at the second check. Therefore, the actual idle thread garbage collection time is between 120 to 240 seconds under the above setting, instead of exactly 120 seconds.
The ThreadPool dispatcher allows a “cooling time” to be set. A thread is said to be “hot” when the GIOP connection being served is potentially readable, either upon creation of the connection or upon the arrival of a request. After the cooling time (in seconds), the thread can be returned to the thread pool. The property can be set statically on server startup or dynamically reconfigured using the property API. For instance, the startup property
The vbroker.se.default.xxx.tp.xxx property is recommended when
vbroker.se.default=iiop_tp. When using with ThreadSession, it is recommended that you use the
vbroker.se.iiop_ts.scm.iiop_ts.xxx property.
When using the ThreadSession as the dispatcher type, you must set the
se.default property to
iiop_ts.
In thread-per-session, there are no threadMin,
threadMax,
threadMaxIdle, and
coolingTime dispatcher properties. Only the Connection and Manager properties are valid properties for ThreadSession.
The following properties are used to configure connection management. Properties whose names start with vbroker.se are server-side properties. The client side properties have their names starting with
vbroker.ce.
The command line options for VisiBroker 3.x backward-compatibility are less obvious in terms of whether they are client-side or server-side. However, the connection and thread management options that start with the -ORB prefix set the client-side options whereas the options with the
-OA prefix are used for the server-side options. There are no common properties which are used for both client-side and server-side thread and connection management.
sets the initial maximum connection limitation on this server engine to 128. The default value of this property is unlimited (
0 [zero]). When the server engine reaches this limitation, before accepting a new client connection, the server engine needs to reuse an idle connection. This is called connection swapping. When a new connection arrives at the server, it will try to detach the oldest unused connection. If all the connections are busy, the new connection will be dropped. The client may retry again until some timeout expires.
In the following properties, xxx is the server engine name and
yyy is the server connection manager name:
For this purpose, the server manager needs to be enabled, using the property vbroker.orb.enableServerManager=true, and the properties can be obtained through the server manager query either through the Console or through a command-line utility.
A dispatcher's thread pool in VisiBroker has an idle timeout vbroker.se.xxx.scm.xxx.dispatcher.threadMaxIdle. The default value is
300 seconds, and after the idle timeout expires the dispatcher will remove any idle worker threads in the thread pool.
A Server Connection Manager (SCM) has its own garbage collection timeout vbroker.se.xxx.scm.xxx.manager.garbageCollectTimer. The default value is
30 seconds, and after the timeout expires any idle connections are garbage collected.
Since the SCM only garbage collects idle connections, the property vbroker.se.xxx.scm.xxx.manager.connectionMaxIdle needs to be set greater than
0 (zero) in order for connections to go to an idle state. The default value is
0 (zero), which means that a connection is never considered idle and nothing is collected, even if the SCM's garbage collection timeout expires.
When the thread pool worker thread, T1, has been idle for 5 seconds it is immediately removed from the dispatcher's thread pool. The connection,
C1, which has been idle for
5 seconds is only garbage collected by the SCM after
10 seconds.
On the Client side the Client Connection Manager's (CCM) cached connections can be given an idle timeout by setting the property vbroker.ce.xxx.ccm.connectionMaxIdle. The default value is
0 (zero), meaning that the cached connections do not have an idle timeout. Given an idle timeout, the idle cached connections in the connection pool/cache are marked eligible for garbage collection. Unlike the SCM, the CCM has no garbage collection timer, however whenever any connection is being cached it will attempt to garbage collect any cached connections that are marked eligible for collection.