From 65964017c1b721ce29cef198e7146981de602284 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Thu, 4 Feb 2021 22:45:06 +0800 Subject: [PATCH] reduce default max blocking thread count for each worker to 512 / core count --- actix-server/src/worker.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/actix-server/src/worker.rs b/actix-server/src/worker.rs index 9d6d9fa5..defc7306 100644 --- a/actix-server/src/worker.rs +++ b/actix-server/src/worker.rs @@ -168,10 +168,11 @@ pub(crate) struct ServerWorkerConfig { impl Default for ServerWorkerConfig { fn default() -> Self { + // 512 is the default max blocking thread count of tokio runtime. + let max_blocking_threads = std::cmp::max(512 / num_cpus::get(), 1); Self { shutdown_timeout: Duration::from_secs(30), - // default max_blocking_threads is the same as tokio's default - max_blocking_threads: 512, + max_blocking_threads, } } }