does message-io support multiple threads?
18o opened this issue · 3 comments
it seems all adapter or worker are run in one thread, does it support multiple threads like tokio can let the program use whole processor .
Hi @18o,
As you have seen, each node uses one thread to read from the network for all the connections that the node has (you can use other threads to write while you are reading). If you need to get more parallel performance you could split your connections into several nodes, but reading from one connection only can be done from one thread.
tokio
gets mixing thread and network events in a transparent way using an async/await api. Keep in mind that using 8 cores to read from one connection in tokio
will not be faster than using 1 core to read from one connection. What tokio
's offers is an automatic load balance across multiple connections in multiple threads. In scenarios with more connections than threads, you will take better advantage of your processor.
thanks for your response, i'll try use message-io in my project instead of tokio as it's really tiny and simple
I'm glad to hear that! 😃
The intention of message-io
is to leave things as simple as possible (without losing performance as far as possible). I also like so much tokio
, and use it in other projects, but the programming complexity is higher than message-io
. It all depends on the target of your application.