I just wrote a JDBC connection pool using Akka.
It uses an actor to hold a "maxPoolSize" collection of real database connections. The caller asks the pool actor for a connection and receives a Future[Connection]
and the connection's status becomes 'busy' until the caller returns it to the pool on connection.close
. If all the connections are busy, the new incoming request for connection will be placed on a waiting queue (also held by the pool actor). Later when a connection is returned, the waiting request will be fulfilled.
The implementation of this logic is very easy in akka, just dozens of lines of code. However when using the BoneCP Multithread Test to test the performance (i.e. the caller close
the connection immediately when the Future[Connection]
returned by getConnection
is fulfilled. The benchmark traversed
all the close
request and Await
for the result Future
), I found that the Akka version is slower than many other connection pool implementations such as tomcat-jdbc, BoneCP or even commons DBCP.
What I have tried for tuning:
but saw no noticable improvement.
My question is :
By design, it is distributed, and it's very easy to use distributed applications. It supports clustering. It supports Reactive Streams using the Akka Streams module. It is easy to develop highly performant, highly scalable, highly maintainable, and highly available applications using Akka.
Akka is a powerful actor / reactive framework for the JVM. Akka is an extremely high-performance library — you can do Up to 50 million msg/sec on a single machine. Small memory footprint; ~2.5 million actors per GB of the heap. Akka is also resilient by Design and follows the principles of the Reactive Manifesto.
Akka is a toolkit for building highly concurrent, distributed, and resilient message-driven applications for Java and Scala.
Akka is written in Scala, with language bindings provided for both Scala and Java. Akka's approach to handling concurrency is based on the Actor Model.
To answer question #1, this is not a use case where Akka will excel in speed. You have basically taken a problem that is usually solved with a concurrent data-structure optimized for multiple readers and writers and serialized it through a single actor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With