Today I found that, for concurrency in java we have good framework like Akka
and I also found that, there is a reactive programming frameworks like RxJava
for performing multithreading
in application. But I'm still confused! Why are both better than Java Concurrency
framework?
Nowadays reactive programing is mature topic, and most languages have support for Functional Reactive Programing
like Netflix
provide APIs regarding Reactive programming
for more than one language. Rxjava
is one of the api that is used for java
, scala
etc. According to RxJava
, they internally use actors for maintaining multithreading
and Akka
also uses Actors
for multithreading
programming.
So, what is the difference between Akka
and Reactive Programming
approach and why they are good from Java Concurrency
?
Java 8 Streams enable processing of really large collections efficiently, while leveraging multicore architectures. In contrast, RxJava is single-threaded by default (without Schedulers). So RxJava won't take advantage of multi-core machines unless you code that logic yourself.
Akka's approach to handling concurrency is based on the Actor Model. In an actor-based system, everything is an actor, in much the same way that everything is an object in object-oriented design.
RxJava is a Java library that enables Functional Reactive Programming in Android development. It raises the level of abstraction around threading in order to simplify the implementation of complex concurrent behavior.
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.
According to Mathias Doenitz at this point in time RxJava doesn't have back pressure unlike Akkas Reactive Streams implementation. But RxJava seems to be working on adding back pressure.
Both frameworks will be able to interact through the reactive streaming spi. So you will be able to do very very similar things. According to Mathias the difference will be that the Akka implementation is based internally on actors, not on multi-threading. And as a result will be more performant.
My source for this information is a talk that Mathias gave last week at the Dutch Scala user group.
edit: I stand corrected wrt back pressure support in RxJava. If you follow Eriks link you can read what back pressure means.
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