SQL Server – How to Calculate Max Number of Worker Threads

cpumulti-threadsql server

I use 64-bit OS with two CPUs (each of them makes 7 logical processors) and with total number of logical processors equal to 14.

When I run this code I get 2048

SELECT max_workers_count FROM sys.dm_os_sys_info

On the other way, when I use the formula below I get totally different number which is 672

For a 64-bit operating system:
Total available logical CPUs <= 4
Max Worker Threads = 512
Total available logical CPUs > 4
Max Worker Threads = 512 + ((logical CPUs - 4)*16)

Can you explain to me why I get different numbers? I tested it on another server and got exact same numbers for both cases.

EDIT

enter image description here

P.S Thanks to Dan Guzman for his suggestions to check server settings for max worker threads. That is what EXEC sp_configure 'max worker threads' returns:

enter image description here

Best Answer

It seems someone has changed the maximum worker threads setting to a non-default value, which will override the default calculated value. The current configured value can be determined with:

EXEC sp_configure 'max worker threads';

I'll add the value is sometimes set mistakenly as a knee-jerk reaction to address symptoms rather than the underlying cause. Some valid reasons for configuring the value are called out in the documentation but the default calculation is appropriate for most workloads.