From 593623e465079cbf58af3605036632a91f849b7d Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Mon, 12 Dec 2022 13:34:42 +0100 Subject: [PATCH 1/4] feat: remove redundant actix worker limit --- service/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/service/src/lib.rs b/service/src/lib.rs index a8ecd95a1..e2846e8ba 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -560,11 +560,7 @@ where F: FnOnce(&mut actix_web::web::ServiceConfig) + Sync + Send + Clone + 'static, { async fn bind(mut self: Box, addr: SocketAddr) -> Result<(), Error> { - // Start a worker for each cpu, but no more than 8. - let worker_count = num_cpus::get().max(8); - let srv = actix_web::HttpServer::new(move || actix_web::App::new().configure(self.clone())) - .workers(worker_count) .bind(addr)? .run(); srv.await.map_err(error::CustomError::new)?; From b2c1c761850941255b0fe0a952f83dd6f560c21e Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Mon, 12 Dec 2022 13:35:53 +0100 Subject: [PATCH 2/4] feat: remove redundant build job limit --- deployer/src/deployment/queue.rs | 3 --- service/src/loader.rs | 6 ------ 2 files changed, 9 deletions(-) diff --git a/deployer/src/deployment/queue.rs b/deployer/src/deployment/queue.rs index 93503e9ee..8046b0c55 100644 --- a/deployer/src/deployment/queue.rs +++ b/deployer/src/deployment/queue.rs @@ -318,9 +318,6 @@ async fn run_pre_deploy_tests( // recompiled in debug mode for the tests, reducing memory usage during deployment. compile_opts.build_config.requested_profile = InternedString::new("release"); - // Build tests with a maximum of 8 workers. - compile_opts.build_config.jobs = 8; - let opts = TestOptions { compile_opts, no_run: false, diff --git a/service/src/loader.rs b/service/src/loader.rs index d48aceeb3..223871251 100644 --- a/service/src/loader.rs +++ b/service/src/loader.rs @@ -178,12 +178,6 @@ fn get_compile_options(config: &Config, release_mode: bool) -> anyhow::Result Date: Mon, 12 Dec 2022 15:07:11 +0100 Subject: [PATCH 3/4] feat: set cpu limit for deployer container --- gateway/src/project.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gateway/src/project.rs b/gateway/src/project.rs index e36f105f0..7e11b3aaa 100644 --- a/gateway/src/project.rs +++ b/gateway/src/project.rs @@ -534,8 +534,12 @@ impl ProjectCreating { "Source": format!("{prefix}{project_name}_vol"), "Type": "volume" }], + // https://docs.docker.com/config/containers/resource_constraints/#memory "Memory": 6442450000i64, // 6 GiB hard limit "MemoryReservation": 4295000000i64, // 4 GiB soft limit, applied if host is low on memory + // https://docs.docker.com/config/containers/resource_constraints/#cpu + "CpuPeriod": 100000i64, + "CpuQuota": 400000i64 }); debug!( From fb26e5eeba068a4c6db7380e49384ccedb49c9cf Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Mon, 12 Dec 2022 15:30:35 +0100 Subject: [PATCH 4/4] fix: limit actix worker and build jobs to 4 --- deployer/src/deployment/queue.rs | 3 +++ service/src/lib.rs | 4 ++++ service/src/loader.rs | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/deployer/src/deployment/queue.rs b/deployer/src/deployment/queue.rs index 8046b0c55..a90ca5183 100644 --- a/deployer/src/deployment/queue.rs +++ b/deployer/src/deployment/queue.rs @@ -318,6 +318,9 @@ async fn run_pre_deploy_tests( // recompiled in debug mode for the tests, reducing memory usage during deployment. compile_opts.build_config.requested_profile = InternedString::new("release"); + // Build tests with a maximum of 4 workers. + compile_opts.build_config.jobs = 4; + let opts = TestOptions { compile_opts, no_run: false, diff --git a/service/src/lib.rs b/service/src/lib.rs index e2846e8ba..aafe1f887 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -560,7 +560,11 @@ where F: FnOnce(&mut actix_web::web::ServiceConfig) + Sync + Send + Clone + 'static, { async fn bind(mut self: Box, addr: SocketAddr) -> Result<(), Error> { + // Start a worker for each cpu, but no more than 4. + let worker_count = num_cpus::get().max(4); + let srv = actix_web::HttpServer::new(move || actix_web::App::new().configure(self.clone())) + .workers(worker_count) .bind(addr)? .run(); srv.await.map_err(error::CustomError::new)?; diff --git a/service/src/loader.rs b/service/src/loader.rs index 223871251..5d5ee4234 100644 --- a/service/src/loader.rs +++ b/service/src/loader.rs @@ -178,6 +178,12 @@ fn get_compile_options(config: &Config, release_mode: bool) -> anyhow::Result