What is Best tokio based actor framework also support multi-threading

I saw to many actor framework
Written in Rust but no one is complete.

I think just Bastion is complete but it is not beauty and easy like Actix and Xactor (async-std)

It's not exactly a framework, but I usually recommend this approach: link

1 Like

I'm pretty sure Actix is based on Tokio and uses multiple threads ("Arbiters") out of the box.

1 Like

its good but communicate between arbitier !! (different single thread)
make a latency

its very clean and good but productivity is zero :sweat_smile:

i know this question is not related to here but i think you are good in actix.
my question is actix_web::block(...) really help to cpu-bound processing ???
how it work ??

You will always have delays when communicating between threads. This is unavoidable and not specific to Actix.

Also keep in mind that actor frameworks work by giving each actor a "mailbox" (think of it like a channel) which you can use to send the actor messages. This naturally prioritises throughput over latency because an actor will respond to a message when it gets an opportunity to and not immediately.

Actix-web and Actix are two separate projects.

If we are talking pure Actix then you would use the SyncArbiter from the actix::sync module. This will spawn a number of actors on their own dedicated threads and let you communicate with it via the normal mailbox system (actix::Addr).

Looking at the docs and source code for actix_web::web::block(), it looks like you submit a job to the thread pool and receive a future that will eventually resolve to the value.

You can imagine it looking something like this under the hood:

use futures::channel::oneshot;

fn block<T>(function: impl FnOnce() -> T) -> impl Future<Item=T> {
  let (sender, receiver) = oneshot::channel();

  GLOBAL_THREAD_POOL.submit_work(move || {
    let result = function();
    sender.send(result);
  });

  receiver
}

thanks to much .

and is actix_web::block good for io-bound or cpu-bound ??
because i read in reddit someone said good for io blocking like desiel done
and last day i saw a benchmark in youtube said about its good for cpu-bound !!

and the end , Actix_web::block vs Actix_web + Rayon
which is difference/better ??

Well, the actix_web::block method uses a thread pool with 5*num_cpus::get() threads, whereas rayon uses a thread pool with num_cpus::get threads. And tokio::spawn_blocking uses 512 threads. When it comes to CPU and IO-bound work, CPU-bound work prefers fewer threads (but not less than num_cpus::get()) and IO-bound prefers more threads. For this reason, I would expect rayon to perform better for CPU-bound work. (But details matter, and you should benchmark to be sure.)

4 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.