The Rust book has a section on multi threaded HTTP server, and I found the corresponding implementation on github.
https://github.com/richardknox/rust-webserver
This was actually published 2 years ago.
While the code is pretty neat, but it is intersting to implement this with crossbeam so that it can directly apply SPMC channel. basically this is typical situation for load balance server.
In fact, the straight forward modification did not work.
it seems better to use hyper.
there is an interesting github, that is quite close to my goal. but it is not using crossbeam.
So it would be better to use this for multi threaded http server imple with crossbeam.
https://github.com/hyperium/hyper/issues/1358
https://gist.github.com/klausi/93b57d3abe2c5bc4975b0b9921f2a3c2
Go program may be useful:
https://github.com/dc0d/tcpserver/blob/master/tcpserver.go
------
After trying to combine crossbeam and tokio, I found this is not simple.
In particular the latest approach of Tokio rely on async, and async and thread seems not easy to coexist.
Once process function includes async code, all code must be async.
And thread's parameter closure should not be async, and the free variable are not permitted because of the lifetime of variable.
there have been some discussion over mpsc channel against mpmc like approach, and if we use these Tokio, hyper library, we may not have to use mpmc at least for http related application.
since it already supports multi threaded handlers.
Anyway I will investigate hyper now. (hyper uses tokio)
https://tokio.rs/
https://hyper.rs/
https://github.com/hyperium/hyper
Subscribe to:
Post Comments (Atom)
Recursive Matrix and the parallel matrix multiplication using crossbeam and generic constant
This was planned project I posted before. Basically in order to evaluate Rust's claim for zero cost abstraction and the effectiveness o...
-
Puppeteer is a powerful tool to control web application at server side using headless chromium. This is mainly used for automated testing,...
-
There are several reverse proxy server. Following crate seems easy to use. https://docs.rs/hyper-reverse-proxy/0.4.0/hyper_reverse_proxy/...
-
There is an interesting article demonstrating how to write channel using Rust: Multithreading in Rust with MPSC (Multi-Producer, Single ...
No comments:
Post a Comment