Earlier quoted context omitted.
And once you get to a limit, the alternative to rewriting everything in non-blocking code might be to put multiple instances of your blocking app on multiple VMs/k8s/whatever behind a load balancer.
Or, you just take the initial leap and write async from the start. For languages with decent abstractions such as async/await, it really isn't hard when you've done it for a while, and I'd make the same argument as one of the parent posters in that it's great "documentation". K8s is brings way more complexity and headache, so it's kind of funny that you suggest that before using async/await.
Tokio 1.0 – async runtime for Rust
231–240 of 422 posts
Re: Tokio 1.0 – async runtime for Rust
#232Earlier quoted context omitted.
Yes. There are some difficult technical issues. In practice, borrow checker works less well on async code than threaded code. This is partly why I prefer threading over async in Rust. Look, we went through some enormous effort to make threading good and fun again. Why wouldn't you use threading?
> Why wouldn't you use threading? Because the C10^nK problem where n increases periodically is still a thing?
Re: Tokio 1.0 – async runtime for Rust
#233Earlier quoted context omitted.
If you know that there will be 10k concurrent users in your application, go ahead and use async right from the start. But for the rest of us, simple, blocking code will do just fine and save us a few headaches.
Alternatively use async everywhere from the start and your headaches go away too. It's mixing blocking code with async code that causes issues.
Re: Tokio 1.0 – async runtime for Rust
#234Earlier quoted context omitted.
> A non-async function is "regular logic", it must complete without blocking. Maybe one can enforce this convention in the particular project, but there's no ecosystem-wide consensus on this, and in fact I don't want this to be consensus. I write blocking non-async functions every day. Why am I wrong to do so?
I believe the idea is that within a project that uses async functionality, you should only use non-async functions when the logic does not call blocking functionality. If you are mixing async functionality and synchronous functions with/blocking I would consider the latter a defect unless it is handled properly within an asynchronous context.
An async system which poisons the rest of my code to force async usage doesn't seem like it will scale to code leveraging multiple libraries and will likely fail at the first lib where the author decided not to bother. The beauty of coroutines in go and Java(soon) is that the async functionality remains local to the code that can make use of it - everyone else just sees a thread-like API.
Re: Tokio 1.0 – async runtime for Rust
#235Earlier quoted context omitted.
>Threads, obviously, accomplish the same thing, and arguably more easily. But threads have a performance problem when they must interact heavily. Cross-thread communication is expensive. I didn't know that cross "async" communication was cheaper, that does seem like a good selling point, but what exactly makes it cheaper? After all threads share the same address space, so you can just pass pointers around the same wa…
I think the point is that you can omit atomics in async case, if you are always using async in single thread mode.
Re: Tokio 1.0 – async runtime for Rust
#236Earlier quoted context omitted.
There is consensus in some ecosystems. Javascript absolutely maintains that invariant. There are (almost) no blocking functions in the javascript / node standard libraries and we work hard to keep it that way. Go maintains similar discipline at the OS syscall level. I feel like the "what color is your function" thing is incomplete. There are arguably 3 types of functions: - Functions which do all their work synchrono…
We are talking about Rust. There is no consensus in Rust.
Re: Tokio 1.0 – async runtime for Rust
#237Earlier quoted context omitted.
Programmers cannot get threading right, but Rust can.
Rust won't magically make your threaded code blocks right. It can just provide you tools to ensure that memory won't leak. It's just 1/10 of the solution.
Re: Tokio 1.0 – async runtime for Rust
#238Earlier quoted context omitted.
Programmers cannot get threading right, but Rust can.
Rust won't magically make your threaded code blocks right. It can just provide you tools to ensure that memory won't leak. It's just 1/10 of the solution.
Re: Tokio 1.0 – async runtime for Rust
#239Re: Tokio 1.0 – async runtime for Rust
#240Earlier quoted context omitted.
If you know that there will be 10k concurrent users in your application, go ahead and use async right from the start. But for the rest of us, simple, blocking code will do just fine and save us a few headaches.
Alternatively use async everywhere from the start and your headaches go away too. It's mixing blocking code with async code that causes issues.