Async rust – are we doing it all wrong?

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • Rouille, Rust web server middleware

    Web framework in Rust (by tomaka)

  • Your CRUD web application server almost certainly doesn't need async Rust. Using a blocking HTTP server is not "might be a good idea", it simply is a good idea.

    I recommend Rouille for this: https://github.com/tomaka/rouille. In case you are worried about performance, check the benchmark. Blocking Rouille is faster than builtin async server in Node.js.

  • quinn

    Async-friendly QUIC implementation in Rust

  • > Making things thread safe for runtime-agnostic utilities like WebSocket is yet another price we pay for making everything multi-threaded by default. The standard way of doing what I'm doing in my code above would be to spawn one of the loops on a separate background task, which could land on a separate thread, meaning we must do all that synchronization to manage reading and writing to a socket from different threads for no good reason.

    Why so? Libraries like quinn[1] define "no IO" crate to define runtime-agnostic protocol implementation. In this way we won't suffer by forcing ourselves using synchronization primitives.

    Also, IMO it's relatively easy to use Send-bounded future in non-Send(i.o.w. single-threaded) runtime environment, but it's almost impossible to do opposite. Ecosystem users can freely use single threaded async runtime, but ecosystem providers should not. If you want every users to only use single threaded runtime, it's a major loss for the Rust ecosystem.

    Typechecked Send/Sync bounds are one of the holy grails that Rust provides. Albeit it's overkill to use multithreaded async runtimes for most users, we should not abandon them because it opens an opportunity for high-end users who might seek Rust for their high-performance backends.

    [1]: https://github.com/quinn-rs/quinn

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • dream-programming-language

    notes on my dream programming language

  • How would you do control flow and scheduling and parallelism and async efficiently with this code?

    `db.save()`, `download()` are IO intensive whereas `document.query("a")` and `parse` is CPU intensive.

    I think its work diagram looks like this: https://github.com/samsquire/dream-programming-language/blob...

    I've tried to design a multithreaded architecture that is scalable which combines lightweight threads + thread pools for work + control threads for IO epoll or liburing loops:

    Here's the high level diagram:

    https://github.com/samsquire/ideas5/blob/main/NonblockingRun...

    The secret is modelling control flow as a data flow problem and having a simple but efficient scheduler.

    I wrote about schedulers here and binpacking work into time:

    https://github.com/samsquire/ideas4#196-binpacking-work-into...

    I also have a 1:M:N lightweight thread scheduler/multiplexer:

    https://github.com/samsquire/preemptible-thread

  • ideas5

    Batch 5 of Ideas for Computing

  • How would you do control flow and scheduling and parallelism and async efficiently with this code?

    `db.save()`, `download()` are IO intensive whereas `document.query("a")` and `parse` is CPU intensive.

    I think its work diagram looks like this: https://github.com/samsquire/dream-programming-language/blob...

    I've tried to design a multithreaded architecture that is scalable which combines lightweight threads + thread pools for work + control threads for IO epoll or liburing loops:

    Here's the high level diagram:

    https://github.com/samsquire/ideas5/blob/main/NonblockingRun...

    The secret is modelling control flow as a data flow problem and having a simple but efficient scheduler.

    I wrote about schedulers here and binpacking work into time:

    https://github.com/samsquire/ideas4#196-binpacking-work-into...

    I also have a 1:M:N lightweight thread scheduler/multiplexer:

    https://github.com/samsquire/preemptible-thread

  • ideas4

    An Additional 100 Ideas for Computing https://samsquire.github.io/ideas4/

  • How would you do control flow and scheduling and parallelism and async efficiently with this code?

    `db.save()`, `download()` are IO intensive whereas `document.query("a")` and `parse` is CPU intensive.

    I think its work diagram looks like this: https://github.com/samsquire/dream-programming-language/blob...

    I've tried to design a multithreaded architecture that is scalable which combines lightweight threads + thread pools for work + control threads for IO epoll or liburing loops:

    Here's the high level diagram:

    https://github.com/samsquire/ideas5/blob/main/NonblockingRun...

    The secret is modelling control flow as a data flow problem and having a simple but efficient scheduler.

    I wrote about schedulers here and binpacking work into time:

    https://github.com/samsquire/ideas4#196-binpacking-work-into...

    I also have a 1:M:N lightweight thread scheduler/multiplexer:

    https://github.com/samsquire/preemptible-thread

  • preemptible-thread

    How to preempt threads in user space

  • How would you do control flow and scheduling and parallelism and async efficiently with this code?

    `db.save()`, `download()` are IO intensive whereas `document.query("a")` and `parse` is CPU intensive.

    I think its work diagram looks like this: https://github.com/samsquire/dream-programming-language/blob...

    I've tried to design a multithreaded architecture that is scalable which combines lightweight threads + thread pools for work + control threads for IO epoll or liburing loops:

    Here's the high level diagram:

    https://github.com/samsquire/ideas5/blob/main/NonblockingRun...

    The secret is modelling control flow as a data flow problem and having a simple but efficient scheduler.

    I wrote about schedulers here and binpacking work into time:

    https://github.com/samsquire/ideas4#196-binpacking-work-into...

    I also have a 1:M:N lightweight thread scheduler/multiplexer:

    https://github.com/samsquire/preemptible-thread

  • rust-async-examples

    A collection of Rust async exercises

  • I do that of course, and that's one of the easiest ways to use async Rust. In real projects you need much more however. F.ex. I had to code an example of how to add tasks to an already running pool of tasks and posted my findings here: https://github.com/dimitarvp/rust-async-examples/blob/main/e... (there's #2 as well with some more comments and a different approach).

    The fact that I needed to make a GitHub repo and start making show-and-tell demos on how to do various things with async Rust to me is both a red flag and me being diligent BUT it should be more obvious. And promoted in docs.

    Rust started suffering from "you got all the nuts and bolts in place, now build your own solution, son" syndrome which I grew to dislike. Too low-level. I wouldn't mind something akin to e.g. Golang's flowmatic library (check the first two examples at the top of the README): https://github.com/carlmjohnson/flowmatic

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • flowmatic

    Structured concurrency made easy

  • I do that of course, and that's one of the easiest ways to use async Rust. In real projects you need much more however. F.ex. I had to code an example of how to add tasks to an already running pool of tasks and posted my findings here: https://github.com/dimitarvp/rust-async-examples/blob/main/e... (there's #2 as well with some more comments and a different approach).

    The fact that I needed to make a GitHub repo and start making show-and-tell demos on how to do various things with async Rust to me is both a red flag and me being diligent BUT it should be more obvious. And promoted in docs.

    Rust started suffering from "you got all the nuts and bolts in place, now build your own solution, son" syndrome which I grew to dislike. Too low-level. I wouldn't mind something akin to e.g. Golang's flowmatic library (check the first two examples at the top of the README): https://github.com/carlmjohnson/flowmatic

  • gleam

    ⭐️ A friendly language for building type-safe, scalable systems!

  • Keep an eye on gleam lang if you’re not already. It’s a language with an ML inspired type system (like rust) that compiles to erlang. It is likely too nascent to be used in production (in terms of tooling, ecosystem, stability, etc).

    https://gleam.run

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts