Which one of the following methods is faster Tokio Async Task and Hyper HTTP response handling?
⚓ Rust 📅 2025-09-19 👤 surdeus 👁️ 8I noticed there are several ways of spawning async task and sending response in Hyper
// pseudo code
// spawning async task
// 1
let runtime = tokio::runtime
let handle = runtime.handle()
let handle2 = handle.clone()
runtime.block_on(
handle.spawn(async move {
loop {
handle2.spawn(async move {
}
}
})
)
// 2
let runtime = tokio::runtime
let handle = runtime.handle()
let handle2 = handle
runtime.block_on(
tokio::task::spawn(async move {
loop {
tokio::task::spawn(async move {
}
}
})
)
// sending response
// 1
hyper::Response::new(String)
// 2
hyper::Response::new(http_body_util::Full::from(Vec<u8>))
// 3
hyper::Response::new(http_body_util::Full::from(hyper::body::Bytes::from(Vec<u8>)))
// 4
hyper::Response::new(http_body_util::Full::from(Vec<u8>).boxed())
What are the pros and cons of that methods? and which one is the highest performance?
2 posts - 2 participants
🏷️ Rust_feed