> # About SequeLink® Threading Models

> The type of connection model you choose for your SequeLink configuration partly depends on your SequeLink Server platform, the scalability requirements, and whether you are using the distributed transaction functionality of a DBMS. SequeLink provides the following types of connection models:

> - The ThreadPool connection model starts SequeLink with a preallocated minimum number of threads that can be increased when needed to a specified maximum number of threads. These threads can be shared by multiple SequeLink Clients connected to the SequeLink Server. This connection model provides optimum scalability-many client connections can be serviced with the same system resources on the server. It is the default connection model for all platforms. (ServiceConnectionModel=ThreadPool)

> NOTE: If you are using distributed transactions with DB2 Universal Database (UDB) on Linux, UNIX, or Windows platforms, do not use the ThreadPool connection model; use the Process/Connection model.

> See "Allocating the Number of Threads to the Thread Pool" and "Returning Threads to the Thread Pool" for more information about configuring how the thread-pool engine operates.

> - The Process/Connection connection model creates a separate operating system process for each SequeLink Client connection request. This connection model is not valid on z/OS. (ServiceConnectionModel=Process/Connection)

> NOTE: If you are using distributed transactions with DB2 UDB on Linux, UNIX, or Windows platforms, use this model.

> - The Thread/Connection connection model provides a dedicated thread for each SequeLink Client connection to a SequeLink Server. Use the Thread/Connection connection model for client applications that are database-intensive, such as bulk load or bulk transfer applications. (ServiceConnectionModel=Thread/Connection)

> See "SequeLink® Service Attributes" for more information about service attributes.

> ### Allocating the Number of Threads to the Thread Pool

> SequeLink can accommodate both low and high user activity by using a minimum number of pre-started threads in the thread pool that can be dynamically increased to accommodate peak user activity. When the SequeLink Server is started, the number of threads specified by the ServiceMinThreads service attribute will populate the thread pool to wait for data access requests from SequeLink Clients. If, during the working day, frequent user activity causes the number of threads specified by ServiceMinThreads to be active concurrently, SequeLink Server will dynamically create additional threads up to the number specified by the ServiceMaxThreads service attribute.

> NOTE: On z/OS, a thread is equivalent to an attached TCB.

> ### Returning Threads to the Thread Pool

> SequeLink allows you to accommodate idle periods and heavy workload traffic by setting service attributes that let you govern when threads are returned to the thread pool, and consequently, when the threads become available to service other client connections.

> The DataSourceThreadMaxRpc attribute specifies the maximum number of data access requests to be accepted from the same client before the thread allocated to that connection is returned to the thread pool. For example, if DataSourceThreadMaxRpc=10, the thread will not be returned to the thread pool until after 10 requests have been made. When the time specified by the DataSourceThreadRpcTimeOut attribute has been exceeded, the thread is returned to the thread pool to serve another connection. This attribute avoids a client connection monopolizing a thread by not responding to it in a timely manner.

> The ServiceThreadLockThreshold attribute specifies a percentage of the value specified by the ServiceMaxThreads attribute. When the number of active threads is less than this percentage, a connection that has executed more RPCs than the value specified by the DataSourceThreadMaxRpc attribute on the current thread is allowed to lock this thread for the time specified by the DataSourceThreadRpcTimeOut attribute. For example, if ServiceMaxThreads=10 and ServiceThreadLockThreshold=50, and only 4 threads are active, a connection can lock the thread it is using for another time period specified by the DataSourceThreadRpcTimeOut attribute.

> These data source attributes ensure that the SequeLink Server can continue to process additional client data access requests, even under heavy workload conditions that can cause all threads to be active concurrently.