# Why akka tell message is much slower than Java TheadPoolExcutor submit？

**URL:** <https://discuss.akka.io/t/why-akka-tell-message-is-much-slower-than-java-theadpoolexcutor-submit/10066>\
**Category:** Akka Libraries\
**Tags:** akka, akka-typed, java\
**Created:** [November 3, 2022, 3:39am UTC](https://discuss.akka.io/t/why-akka-tell-message-is-much-slower-than-java-theadpoolexcutor-submit/10066 "2022-11-03T03:39:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ye](https://avatars.discourse-cdn.com/v4/letter/y/f0a364/32.png) [@ye](https://discuss.akka.io/u/ye)\
**Post date:** [November 3, 2022, 3:39am UTC](https://discuss.akka.io/t/why-akka-tell-message-is-much-slower-than-java-theadpoolexcutor-submit/10066/1 "2022-11-03T03:39:30Z")

</div>

Our company’s engine is built with akka and we are doing performance stress testing.  
We found that akka tell message is very slow，100 message use about 5-6ns.  
The result confused us，so we do a test  
（1）send 100 message to 100 actors，calculate time  
（2）send 100 task to TheadPoolExcutor，calculate time  
dispatcher and TheadPoolExcutor are both 32 threads  
but the result is different  
actors use 5-6ns and TheadPoolExcutor use 0-1ns  
Can someone help us see what’s going on in akka?  
The test code is here

> **[GitHub - maristonchen/akka-sample](https://github.com/maristonchen/akka-sample)**
>
> Contribute to maristonchen/akka-sample development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![johanandren](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/johanandren/32/85_2.png) [@johanandren](https://discuss.akka.io/u/johanandren)\
**Post date:** [November 3, 2022, 10:51am UTC](https://discuss.akka.io/t/why-akka-tell-message-is-much-slower-than-java-theadpoolexcutor-submit/10066/2 "2022-11-03T10:51:22Z")

</div>

Are you talking about the time it takes for tell to hand off the message to the mailbox and return vs enqueueing a runnable to a thread pool, not the time it takes to actually schedule and execute the workload?

There isn’t much going on in that execution path, an allocation, some indirection, but probably more than in the thread pool.

The actor model provides quite a deal more than just executing a workload like `Runnable` - a way to safely interact with mutable state from multiple threads via messages, a lifecycle for the state (actor), and the possibility to do the interaction in the same way for local and distributed actors across multiple machines.

This comes with some small cost compared to just running a set of isolated `Runnable` instances. Just like scheduling tasks on a thread pool comes with a cost compared to running them directly in the same thread in a while loop.
