Thread-per-Request: Top 3 Scalability Hurdles
High memory consumption per thread, significant context switching overhead for large numbers of concurrent connections, and the risk of thread pool exhaustion are primary scalability challenges for CPU-bound tasks.
The top 3
- Memory Footprint: The #1 Thread-per-Request Resource Hog: Each thread in a thread-per-request model requires a dedicated memory stack, often defaulting to 1MB in 64-bit JVMs, which can quickly lead to gigabytes of RAM consumption and resource exhaustion when handling thousands of concurrent requests.
- Context Switching: The Hidden Performance Tax: High thread counts in thread-per-request models lead to frequent context switches by the OS, consuming valuable CPU cycles for saving and restoring CPU state, impacting cache performance, and increasing overall latency and reducing throughput.
- Lock Contention: Bottlenecking Shared Resources: When multiple threads in a thread-per-request server try to access shared resources concurrently, they often contend for locks, forcing threads to wait and leading to a significant decrease in throughput and increased latency, especially as concurrency rises.
Sources
Open the full topic