Comments (9)
Indeed!
There is now an accompanying guide to the chat example: https://tokio.rs/docs/getting-started/chat/
I'm going to close this issue as the general "more realistic demos" issue has been handled. However, there is definitely still a need for more examples that cover real world cases. So, I would say that new issues should be created with specific example proposals.
from tokio.
Thanks for the report, and it's definitely our desire to have realistic examples! If you've got some suggestions for what you'd like to see, please just let me know!
from tokio.
Thanks for being so responsive. For what it's worth I don't know how valuable this is for anyone else but this is reflective of my experience going through the tokio.rs and tokio-core examples.
Something that might be immediately helpful is providing more of a readme for the examples in tokio-core that explains some of the high level concepts that the example(s) show. I definitely missed out on some really useful examples in them by skipping over ones that didn't seem relevant to what I was working on.
To me personally moving through the documentation on tokio.rs and then to the examples was sort of a stretch. A lot of the steps on tokio.rs felt very siloed and it didn't feel like there was really a clear progression through them. Maybe keeping the same sections but using each one to build on the previous to build a single complete example rather than sort of disjointed separate examples would be helpful. To me it wasn't really clear how a lot of the parts fit together until I was able to find more complete code and get people to answer questions I had.
With respect to the udp-codec example I think something that would be more useful is to modify it so that you can run multiple instances (one for the ping and one for the pong) that communicate with each other. The way that the streams and sinks work in it was personally very confusing trying to understand the back and forth. Now that I understand how it works it's a lot more clear but it just seemed sort of awkward if that makes any sense.
Something I've noticed in the examples with the worker paradigm with each worker getting a channel and the event loop round robin distributes requests to them. This is super awesome but some discussion of it on tokio.rs would be cool to understand a bit more about where it makes sense to use it and where it doesn't.
Something I'm also not really clear about from the examples on tokio.rs and in tokio-core utilizing multiple cores/threads to handle processing from the non-blocking I/O efficiently without blocking new connections. CpuPools are introduced on tokio.rs for cpu intensive tasks but they're ignored in the examples with workers. Some high level discussion and some examples around that would be awesome to just understand what the best practices are around that and how the different abstractions around I/O and computation fit together.
from tokio.
For what it's worth I don't know how valuable this is for anyone else but this is reflective of my experience going through the tokio.rs and tokio-core examples.
Nah this is great, thanks for writing this out! The documentation on tokio.rs can definitely use a lot of improvements, and this sort of feedback is invaluable :)
Something that might be immediately helpful is providing more of a readme for the examples in tokio-core that explains some of the high level concepts that the example(s) show
A great idea!
With respect to the udp-codec example I think something that would be more useful is to modify it so that you can run multiple instances
Sonds like a great idea to me, mind opening an issue on the tokio-core repository?
Something I've noticed in the examples with the worker paradigm with each worker getting a channel and the event loop round robin distributes requests to them
Heh these were added in probably the last 48 hours, so tokio.rs hasn't quite caught up just yet :). In general we've got a lot of planned improvements for the tokio.rs documentation we hope to get done during the impl period for Rust!
Something I'm also not really clear about from the examples on tokio.rs and in tokio-core utilizing multiple cores/threads to handle processing from the non-blocking I/O efficiently without blocking new connections
Definitely, I'll see if I can add an example of CPU intensive work.
from tokio.
I've just added an example of CPU intensive work, let me know what you think!
from tokio.
I'll get an issue filed for tokio-core and would be happy to give writing the change a shot and submit a pull request.
Thanks for adding the example for mixing the CpuCore and the Reactor, that's super helpful. The one thing I guess I'm still not 100% clear on is what sort of situations make sense to spawn a worker per thread and shove off the processing to one vs. putting the processing work into a CpuPool and returning a future? Is the CpuPool going to do a better job of scheduling the work across threads than a round robin approach or are they solving different problems?
from tokio.
would be happy to give writing the change a shot and submit a pull request.
That'd be awesome!
The one thing I guess I'm still not 100% clear on is what sort of situations make sense to spawn a worker per thread and shove off the processing to one vs. putting the processing work into a CpuPool and returning a future? Is the CpuPool going to do a better job of scheduling the work across threads than a round robin approach or are they solving different problems?
In general this depends on your workload as to which you should choose. If everything you do is I/O bound but you still need higher throughput after just using one core you can use multiple I/O threads, but this ends up being a very rare paradigm to use in practice.
Much more common is to use worker threads, where you keep all your work off the main I/O loop to prevent it from blocking.
from tokio.
Relates to #13
from tokio.
That's a good example! https://github.com/tokio-rs/tokio/blob/master/examples/chat.rs
from tokio.
Related Issues (20)
- Proposed list of Metrics to Stabilize HOT 5
- Ability to split a JoinSet into spawn and join halves HOT 1
- runtime metrics blocking threads miscount
- Add File::create_new convenience c'tor HOT 1
- Tonic server uses encapsulation HOT 2
- Missing methods `join_set::Builder::spawn_blocking()` and `join_set::Builder::spawn_blocking_on()` HOT 2
- Add a `CancellationToken` method for running a future until completion or cancellation HOT 1
- CI failure on windows HOT 3
- Vectored IO for `write_all_buf` HOT 1
- Doc bug in `Command::stdin`? HOT 1
- Include relevant values in ReadBuf.put_slice() panic message HOT 1
- File IO hangs after timeout / cancellation HOT 2
- Use `[lints.rust.unexpected_cfgs.check-cfg]` instead of hacky check-cfg workaround HOT 2
- Helper struct/wrapper for a stream of named pipe connections HOT 7
- tokio::sync::mpsc::bounded::Receiver<T>::is_empty() returns false when recv().await blocks HOT 3
- Feature tokio::sync::mpsc::Receiver::wait_close(&self) HOT 11
- Panic at linked_list.rs - reborn HOT 5
- Every 32 messages `is_empty()` on `Receiver` and `UnboundedReceiver` returns `false` even though len == 0 HOT 1
- LengthDelimitedCodec misses that last N bytes of the frame with num_skip(0) HOT 1
- Segment fault at `poll_future` HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tokio.