Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Java Concurrency, Akka and RxJava?

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 ?

like image 978
Harmeet Singh Taara Avatar asked Dec 17 '14 12:12

Harmeet Singh Taara


People also ask

What is the difference between Java and RxJava?

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.

How does Akka handle concurrency?

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.

What is reactive programming RxJava?

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.

Is Akka reactive programming?

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.


1 Answers

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.

like image 88
Joost de Vries Avatar answered Sep 28 '22 10:09

Joost de Vries