configurable workers
This server will only see occasional traffic so it makes sense to spawn only limited number of workers as opposed to spawning one worker/thread, which is the default behavior. I recommend at least two workers.
This commit is contained in:
parent
48e5672e15
commit
8cd9f0030d
5 changed files with 6 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -926,6 +926,7 @@ dependencies = [
|
||||||
"git2",
|
"git2",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
|
"num_cpus",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
"serde 1.0.130",
|
"serde 1.0.130",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|
|
@ -32,3 +32,5 @@ lazy_static = "1.4"
|
||||||
url = "2.2"
|
url = "2.2"
|
||||||
|
|
||||||
derive_more = "0.99"
|
derive_more = "0.99"
|
||||||
|
|
||||||
|
num_cpus = "1.13"
|
||||||
|
|
|
@ -15,3 +15,4 @@ ip= "0.0.0.0"
|
||||||
domain = "localhost"
|
domain = "localhost"
|
||||||
allow_registration = true
|
allow_registration = true
|
||||||
proxy_has_tls = false
|
proxy_has_tls = false
|
||||||
|
#workers = 2
|
||||||
|
|
|
@ -67,14 +67,13 @@ async fn main() -> std::io::Result<()> {
|
||||||
actix_middleware::DefaultHeaders::new()
|
actix_middleware::DefaultHeaders::new()
|
||||||
.header("Permissions-Policy", "interest-cohort=()"),
|
.header("Permissions-Policy", "interest-cohort=()"),
|
||||||
)
|
)
|
||||||
// .wrap(get_survey_session())
|
|
||||||
// .wrap(get_identity_service())
|
|
||||||
.wrap(actix_middleware::NormalizePath::new(
|
.wrap(actix_middleware::NormalizePath::new(
|
||||||
actix_middleware::TrailingSlash::Trim,
|
actix_middleware::TrailingSlash::Trim,
|
||||||
))
|
))
|
||||||
.configure(services)
|
.configure(services)
|
||||||
// .app_data(data.clone())
|
// .app_data(data.clone())
|
||||||
})
|
})
|
||||||
|
.workers(SETTINGS.server.workers.unwrap_or(num_cpus::get()))
|
||||||
.bind(SETTINGS.server.get_ip())
|
.bind(SETTINGS.server.get_ip())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.run()
|
.run()
|
||||||
|
|
|
@ -30,6 +30,7 @@ pub struct Server {
|
||||||
pub domain: String,
|
pub domain: String,
|
||||||
pub ip: String,
|
pub ip: String,
|
||||||
pub proxy_has_tls: bool,
|
pub proxy_has_tls: bool,
|
||||||
|
pub workers: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Server {
|
impl Server {
|
||||||
|
|
Loading…
Reference in a new issue