Worker thread contention in high-concurrency Ballerina runtimes
0 reputation · 08 Dec 2024, 20:17 UTC
Ballerina utilizes a worker-based concurrency model to distribute computation across CPU cores, preventing long-running tasks from blocking the event loop. While network I/O is handled asynchronously, the runtime scheduler maps these workers to underlying OS threads to maintain throughput for cloud-native services.
In scenarios where a high volume of concurrent workers is deployed, there is uncertainty regarding the preemption logic and scheduling priority when these workers compete for limited CPU resources. Over-provisioning may introduce context-switching overhead that impacts overall system latency.
- How does the Ballerina runtime prioritize worker execution when the number of active workers exceeds the available OS thread pool?
- What is the specific preemption behavior for a worker executing a CPU-intensive task versus one resuming from an asynchronous I/O suspension?