Thread Pooling

Troubleshooting SQL Server

Troubleshooting

Thread Pooling

The Microsoft® SQL Server™ error log may display the message:

The working thread limit of 255 has been reached

This message is an informational message and does not indicate any problem with the system.

SQL Server maintains a pool of operating-system threads for executing batches of SQL statements as they arrive from clients. On Microsoft Windows NT®, if the server lightweight pooling configuration option is set to 1, SQL Server maintains a pool of fibers instead of threads; fibers use fewer resources than threads. Using a pool of threads or fibers allows SQL Server to optimize the allocation of processing time when executing multiple SQL statements at the same time. The threads or fibers in this pool are known collectively as the worker threads. For more information, see Thread and Task Architecture.

The number of worker threads is controlled by the max worker threads server configuration option. The default is 255 and rarely needs to be changed.

When a batch of Transact-SQL statements is received from a client, if an existing worker thread is free, it is allocated to execute the batch. If no existing worker threads are free and the number of worker threads is less than max worker threads, a new worker thread is allocated. If no worker threads are free and max worker threads is reached, the new batch waits until an existing worker thread completes its current batch and becomes free. When the number of worker threads reaches max worker threads, SQL Server displays this message:

The working thread limit of 255 has been reached

Having all worker threads allocated does not mean that the performance of SQL Server will degrade. Typically, a new batch has only a short wait for a free thread. Allocating more threads may degrade performance because of the increased work required to coordinate resources among the threads. Many SQL Server systems running in production reach this state and run with very high performance levels.

See Also

max worker threads Option

Setting Configuration Options

sp_configure