Skip to content

Thread Pool

Thread pool configuration settings for optimizing application performance.

Overview

json
{
  "ThreadPool": {
    "MinWorkerThreads": null,
    "MinCompletionPortThreads": null,
    "MaxWorkerThreads": null,
    "MaxCompletionPortThreads": null
  }
}

Settings Reference

SettingTypeDefaultDescription
MinWorkerThreadsintnullMinimum number of worker threads in the thread pool. Uses system defaults if null.
MinCompletionPortThreadsintnullMinimum number of completion port threads. Uses system defaults if null.
MaxWorkerThreadsintnullMaximum number of worker threads in the thread pool. Uses system defaults if null.
MaxCompletionPortThreadsintnullMaximum number of completion port threads. Uses system defaults if null.

Worker Threads vs Completion Port Threads

  • Worker threads execute CPU-bound work and synchronous operations
  • Completion port threads handle asynchronous I/O operations (database queries, HTTP requests)

When to Configure

The default thread pool settings work well for most scenarios. Consider adjusting when:

  • High-concurrency workloads cause thread pool starvation
  • Application experiences delays during burst traffic
  • Profiling indicates thread pool bottlenecks

Example Configuration

High-concurrency configuration:

json
{
  "ThreadPool": {
    "MinWorkerThreads": 100,
    "MinCompletionPortThreads": 100,
    "MaxWorkerThreads": 500,
    "MaxCompletionPortThreads": 500
  }
}

WARNING

Setting thread pool values too high can increase memory usage and context switching overhead. Test thoroughly before deploying to production.

Next Steps

Released under the MIT License.