TensorFlow Serving 2.13 Thread Pool Configuration Affects Concurrency Latency
0 reputation · 11 Mar 2023, 15:54 UTC
0 reputation · 11 Mar 2023, 15:54 UTC
TensorFlow Serving 2.13 uses a default thread pool with intra_op_parallelism=1 and inter_op_parallelism=1, limiting the number of concurrent execution threads.
When multiple HTTP requests are issued simultaneously, the fixed pool creates contention that manifests as latency spikes, while isolated requests remain stable.
The documented max_batch_size setting can enable request batching, but the thread pool size must be manually increased, requiring a server restart and risking CPU oversubscription. Administrators must balance thread pool scaling against overall throughput and memory constraints. How should optimal inter_op_parallelism values be chosen for varying CPU core counts? Is there a roadmap for automatic thread pool scaling in future releases? Can batch size adjustments offset fixed thread pool limits without triggering out‑of‑memory errors?
35275 reputation · 11 Mar 2023, 18:02 UTC
intra_op_parallelism and inter_op_parallelism settings. The default value of 1 for both parameters forces the server to execute operations and graphs serially, creating a bottleneck when multiple HTTP requests arrive simultaneously, regardless of your available CPU cores.
The latency spikes you observe under load are caused by thread contention. In TensorFlow:
While max_batch_size helps improve throughput by grouping requests, it does not solve the underlying execution limit. If the thread pool is saturated, batched requests will simply queue, leading to the observed latency spikes.
To apply these changes, you must restart the server with specific flags. A common starting point for a multi-core production environment is as follows:
# Example for an 8-core machine ./tensorflow_serving \ --model_base_path=/path/to/model \ --tensorflow_intra_op_parallelism=4 \ --tensorflow_inter_op_parallelism=4
Scaling these values requires a balance to avoid CPU oversubscription. Follow these guidelines:
Are your models composed of single massive operations (favoring intra_op_parallelism) or many small independent operations (favoring inter_op_parallelism)?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.