Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/set cpu limit #529

Merged
merged 4 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deployer/src/deployment/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ 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;
// Build tests with a maximum of 4 workers.
compile_opts.build_config.jobs = 4;

let opts = TestOptions {
compile_opts,
Expand Down
4 changes: 4 additions & 0 deletions gateway/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
4 changes: 2 additions & 2 deletions service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,8 @@ where
F: FnOnce(&mut actix_web::web::ServiceConfig) + Sync + Send + Clone + 'static,
{
async fn bind(mut self: Box<Self>, addr: SocketAddr) -> Result<(), Error> {
// Start a worker for each cpu, but no more than 8.
let worker_count = num_cpus::get().max(8);
// 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)
Expand Down
4 changes: 2 additions & 2 deletions service/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ fn get_compile_options(config: &Config, release_mode: bool) -> anyhow::Result<Co
InternedString::new("dev")
};

// This sets the max workers for cargo build to 8 for release mode (aka deployment),
// This sets the max workers for cargo build to 4 for release mode (aka deployment),
// but leaves it as default (num cpus) for local runs
if release_mode {
opts.build_config.jobs = 8
opts.build_config.jobs = 4
};

Ok(opts)
Expand Down