reduce default max blocking thread count for each worker to 512 / core count

This commit is contained in:
fakeshadow 2021-02-04 22:45:06 +08:00
parent 7f9394734a
commit 65964017c1
1 changed files with 3 additions and 2 deletions

View File

@ -168,10 +168,11 @@ pub(crate) struct ServerWorkerConfig {
impl Default for ServerWorkerConfig { impl Default for ServerWorkerConfig {
fn default() -> Self { 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 { Self {
shutdown_timeout: Duration::from_secs(30), shutdown_timeout: Duration::from_secs(30),
// default max_blocking_threads is the same as tokio's default max_blocking_threads,
max_blocking_threads: 512,
} }
} }
} }