{
  "id": 18149078,
  "title": "Your .NET parallel loop can become serial in a one-CPU container",
  "url": "https://urgent.news/2026/11/04/your-net-parallel-loop-can-become-serial-in-a-one-cpu-container",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-04T16:34:13.000Z",
  "source": {
    "name": "Stack Overflow Blog",
    "slug": "stack-overflow-blog",
    "url": "https://stackoverflow.blog/2026/11/04/your-net-parallel-loop-can-become-serial-in-a-one-cpu-container/"
  },
  "original_language": "en",
  "account": "A .NET parallel loop can unexpectedly behave like a serial loop when running in a one-CPU container, leading to increased processing times. For example, processing 200 records took 42.1 seconds when the container was allowed two CPUs, but 83.6 seconds when limited to one CPU. This slowdown occurs because the container's CPU limit forces the loop to process records sequentially, one at a time, instead of concurrently. The issue arises from the Parallel.ForEachAsync method, which defaults to using the maximum number of processors available. When the CPU limit is set to one, this limit is applied to the default concurrency level, causing the loop to run sequentially. To avoid this issue, explicitly specify a concurrency level using ParallelOptions, or use a cancellation token with Parallel.ForEachAsync. Configuring separate concurrency limits for different services allows for efficient resource utilization and prevents overload.",
  "summary": "CPU-based defaults can leave an I/O-heavy loop processing one record at a time. Raising the limit helps, but each downstream service still needs a concurrency budget it can handle.",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}