{"id":1123,"date":"2026-11-12T22:41:03","date_gmt":"2026-11-12T22:41:03","guid":{"rendered":"https:\/\/windows-vps.org\/blog\/?p=1123"},"modified":"2026-11-12T22:41:03","modified_gmt":"2026-11-12T22:41:03","slug":"aspnet-core-thread-pool-starvation-iis-counters","status":"publish","type":"post","link":"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/","title":{"rendered":"Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test"},"content":{"rendered":"<div style=\"padding:20px\">\n\n<p class=\"wp-block-paragraph\">Requests to an ASP.NET Core app on IIS start taking 3 to 15 seconds while CPU sits at 20 percent. Thread count is high, throughput in <code>Microsoft.AspNetCore.Server.Kestrel<\/code> request counters collapses, and the app recovers by itself after a few minutes of quiet. Nothing appears in the event log, no 500s are returned, and a restart clears it for an hour. That pattern is thread-pool starvation: every worker is blocked waiting on something, so newly injected threads cannot pick up queued work fast enough.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The reason it hides so well is that starvation looks like slowness, not failure. Latency rises, requests still complete, and the machine reports idle CPU. Capacity planning based on CPU graphs will never surface it; you need the counters that describe queue depth and thread injection, and a load profile that reproduces the block. For hosts where the app and IIS share a small core count, look at <a href=\"https:\/\/windows-vps.org\/\">Windows VPS configurations built for ASP.NET Core workloads<\/a> before adding threads as a fix.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The signature in performance counters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add these counters under <code>Process<\/code> for the <code>w3wp<\/code> instance: <code>% Processor Time<\/code>, <code>Thread Count<\/code>, <code>Private Bytes<\/code>. Under <code>ASP.NET Core Requests<\/code> or the Kestrel counters exposed via EventSource, watch request rate and average duration. Under <code>.NET CLR LocksAndThreads<\/code>, watch <code># of current logical Threads<\/code> and <code>Contention Rate \/ sec<\/code>. A thread count pinned near the configured minimum with a flat request rate is the classic shape.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The clearest single signal is that thread count sits at the minimum worker thread level, usually the core count, and does not rise despite a full request queue. The runtime injects roughly one thread per 500 ms after that, so a workload that queues 200 blocking operations takes over a minute to drain even after the blocking call returns. During that minute, every request that arrives waits behind work that has already finished.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Find the synchronous block, not the thread count<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Raising thread minimums treats the symptom. The cause is a blocking call on a request thread: <code>.Result<\/code> or <code>.Wait()<\/code> on a task, synchronous database calls in an async controller, <code>File.ReadAllText<\/code> on a network share, a lock held across an await, or a synchronous HTTP client call. Search the codebase for <code>.Result;<\/code>, <code>.Wait()<\/code>, <code>GetAwaiter().GetResult()<\/code>, and <code>Thread.Sleep<\/code> in request paths.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Under a repro, capture a stack dump with <code>dotnet-stack report --process-id &lt;pid&gt;<\/code> or a full dump through Task Manager&#8217;s create dump file option, then inspect with <code>dotnet-dump analyze<\/code>. Count how many threads sit inside the same frame; ten or more worker threads at one call site names the culprit immediately. Two dumps thirty seconds apart separate transient waits from a genuine deadlock.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What the autoscaling of threads really costs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The CLR grows the worker pool conservatively on purpose. Unbounded growth would let a burst of blocking calls consume a gigabyte of stack space and thrash the scheduler. When you call <code>ThreadPool.SetMinThreads(workerThreads, completionPortThreads)<\/code> you shorten that ramp, at the cost of memory and context switching. Set it once at startup, before the first request, in <code>Program.cs<\/code>, not from a controller where it changes behaviour mid-flight.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A reasonable starting point for an API that must survive a known burst is 2 to 4 times the core count, paired with a matching <code>ThreadPool.SetMaxThreads<\/code> ceiling so a runaway does not spiral. On a 4-vCPU instance, 16 minimum worker threads is defensible; 200 is a sign that the real problem was never addressed and the app will fall over at a lower concurrency than before.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">IIS settings that change the math<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In-process hosting under the ASP.NET Core Module runs inside <code>w3wp<\/code>, so the IIS worker process thread pool and the app share a budget. Out-of-process hosting puts Kestrel in <code>dotnet.exe<\/code> behind a proxy hop, which separates the pools but adds a serialization step. If a slow non-async module or an ISAPI filter runs in the same worker, both hosts suffer it. Check the app pool for <code>Maximum Worker Processes<\/code> above 1 on a small box as well; web gardens multiply memory and thread pressure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>processModel<\/code> request queue limits matter too. When the queue fills, IIS returns 503 instead of slow responses, so 503 waves mixed with latency spikes point at the same saturation. Raising <code>requestQueueLimit<\/code> buys time but not capacity.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Build a load test that reproduces it<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use a tool that keeps a fixed concurrency level and reports percentiles: <code>bombardier -c 64 -d 120s http:\/\/127.0.0.1:5000\/api\/orders<\/code>, or <code>wrk<\/code> with a Lua script for a POST body. Run it against the local Kestrel port first, then through IIS, so the proxy hop is ruled out. Record p50, p95, p99 and requests per second at concurrency 8, 32, and 128.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Starvation shows as p50 that stays flat while p99 climbs by an order of magnitude with rising concurrency, then a hard throughput plateau well below what the CPU could deliver. A healthy async app scales until CPU saturates; a starved one plateaus at roughly (threads \/ blocking time) requests per second. Watch the perfmon counters live during the run and note the thread count at the plateau.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Fix the code, then tune the floor<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Convert the blocking paths to async all the way down, using <code>await<\/code> and <code>ConfigureAwait(false)<\/code> in library code. Give the database context an async command timeout you actually enforce and a connection pool size that matches worker concurrency, otherwise async code collapses back into waiting on a connection. Replace per-request locks on hot caches with immutable snapshots or <code>SemaphoreSlim<\/code> awaited asynchronously.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then revisit the minimums and re-run the same test. The threads-per-second slope in the counters tells you whether the change worked: with blocking removed, thread count should barely move at concurrency 128. If it still climbs, an async-over-sync wrapper somewhere is presenting an async signature over a blocking call, and the dump will show the same frame as before.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What to alert on in production<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Alert on the shape rather than a single sample: thread count held above 80 percent of the maximum for two minutes, or p95 latency above threshold while CPU is under 40 percent. Both conditions are cheap to compute and both fire long before user-visible timeouts. Publish the counters from the app itself with EventCounters to Application Insights or a metrics endpoint so you are not dependent on a perfmon session being open.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Record the fix and its measured effect in the runbook next to the pool settings, because the next person to see slow responses will otherwise raise the minimums again. Combined with a host that has headroom for the extra threads, the change holds. If your current instance runs two vCPUs for an API with database round trips, <a href=\"https:\/\/windows-vps.org\/\">step up to a Windows VPS with more cores and memory<\/a> and re-measure before adding any tuning.<\/p>\n\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Requests to an ASP.NET Core app on IIS start taking 3 to 15 seconds while CPU sits at 20 percent. Thread count is high, throughput in Microsoft.AspNetCore.Server.Kestrel request counters collapses, and the app recovers by itself after a few minutes of quiet. Nothing appears in the event log, no 500s are returned, and a restart &#8230; <a title=\"Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test\" class=\"read-more\" href=\"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/\" aria-label=\"Read more about Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1123","post","type-post","status-publish","format-standard","hentry","category-reviews"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test - Windows VPS Blog<\/title>\n<meta name=\"description\" content=\"Requests to an ASP.NET Core app on IIS start taking 3 to 15 seconds while CPU sits at 20 percent. Thread count is high, throughput in\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test\" \/>\n<meta property=\"og:description\" content=\"Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test\" \/>\n<meta property=\"og:url\" content=\"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/\" \/>\n<meta property=\"og:site_name\" content=\"Windows VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-12T22:41:03+00:00\" \/>\n<meta name=\"author\" content=\"windows-vps\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@myxiechengxuan\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"windows-vps\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/\",\"url\":\"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/\",\"name\":\"Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test - Windows VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/#website\"},\"datePublished\":\"2026-11-12T22:41:03+00:00\",\"author\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58\"},\"description\":\"Requests to an ASP.NET Core app on IIS start taking 3 to 15 seconds while CPU sits at 20 percent. Thread count is high, throughput in\",\"breadcrumb\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/windows-vps.org\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#website\",\"url\":\"https:\/\/windows-vps.org\/blog\/\",\"name\":\"Windows VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/windows-vps.org\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58\",\"name\":\"windows-vps\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g\",\"caption\":\"windows-vps\"},\"sameAs\":[\"https:\/\/windows-vps.org\/blog\",\"https:\/\/x.com\/myxiechengxuan\"],\"url\":\"https:\/\/windows-vps.org\/blog\/author\/myxiechengxuan\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test - Windows VPS Blog","description":"Requests to an ASP.NET Core app on IIS start taking 3 to 15 seconds while CPU sits at 20 percent. Thread count is high, throughput in","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/","og_locale":"en_US","og_type":"article","og_title":"Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test","og_description":"Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test","og_url":"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/","og_site_name":"Windows VPS Blog","article_published_time":"2026-11-12T22:41:03+00:00","author":"windows-vps","twitter_card":"summary_large_image","twitter_creator":"@myxiechengxuan","twitter_misc":{"Written by":"windows-vps","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/","url":"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/","name":"Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test - Windows VPS Blog","isPartOf":{"@id":"https:\/\/windows-vps.org\/blog\/#website"},"datePublished":"2026-11-12T22:41:03+00:00","author":{"@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58"},"description":"Requests to an ASP.NET Core app on IIS start taking 3 to 15 seconds while CPU sits at 20 percent. Thread count is high, throughput in","breadcrumb":{"@id":"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/windows-vps.org\/blog\/aspnet-core-thread-pool-starvation-iis-counters\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/windows-vps.org\/blog\/"},{"@type":"ListItem","position":2,"name":"Diagnosing ASP.NET Core Thread-Pool Starvation on IIS with Counters and a Load Test"}]},{"@type":"WebSite","@id":"https:\/\/windows-vps.org\/blog\/#website","url":"https:\/\/windows-vps.org\/blog\/","name":"Windows VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/windows-vps.org\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58","name":"windows-vps","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g","caption":"windows-vps"},"sameAs":["https:\/\/windows-vps.org\/blog","https:\/\/x.com\/myxiechengxuan"],"url":"https:\/\/windows-vps.org\/blog\/author\/myxiechengxuan\/"}]}},"_links":{"self":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/comments?post=1123"}],"version-history":[{"count":1,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1123\/revisions"}],"predecessor-version":[{"id":1124,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1123\/revisions\/1124"}],"wp:attachment":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/media?parent=1123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/categories?post=1123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/tags?post=1123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}