Skip to content

Latest commit

 

History

History
87 lines (68 loc) · 2.7 KB

File metadata and controls

87 lines (68 loc) · 2.7 KB
outline
2
3
title Thread Pool Configuration
titleTemplate NpgsqlRest
description Configure .NET thread pool settings for NpgsqlRest performance. Worker threads, completion ports, and async optimization for high-throughput APIs.
head
meta
name content
keywords
npgsqlrest thread pool, api performance tuning, worker threads configuration, async optimization, high throughput api
meta
property content
og:title
NpgsqlRest Thread Pool Configuration
meta
property content
og:description
Configure thread pool settings for optimal API performance and throughput.
meta
property content
og:type
article

Thread Pool

Thread pool configuration settings for optimizing application performance.

Overview

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

Settings Reference

Setting Type Default Description
MinWorkerThreads int null Minimum number of worker threads in the thread pool. Uses system defaults if null.
MinCompletionPortThreads int null Minimum number of completion port threads. Uses system defaults if null.
MaxWorkerThreads int null Maximum number of worker threads in the thread pool. Uses system defaults if null.
MaxCompletionPortThreads int null Maximum 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:

{
  "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. :::

Related

Next Steps