Replies: 1 comment 1 reply
-
fn main() -> Result<(), Box<dyn std::error::Error>> {
let cpus = 5;
println!("Running with {} threads", cpus);
// Esentially the same as tokio::main, but with number of threads set
tokio::runtime::Builder::new_multi_thread()
.worker_threads(cpus)
.enable_all()
.build()
.unwrap()
.block_on(serve())
}
async fn serve() -> Result<(), Box<dyn std::error::Error>> {
let addr = "0.0.0.0:50051".parse().unwrap();
let greeter = MyGreeter::default();
println!("GreeterServer listening on {}", addr);
Server::builder()
.add_service(GreeterServer::new(greeter))
.serve(addr)
.await?;
Ok(())
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
lmtr0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello there, good day!
I was wondering if the server used any kind of multithreading or multiple processes to parallelize the service. If so, is it possible to set the amount of workers?
Beta Was this translation helpful? Give feedback.
All reactions