lamtrhieu

lamtrhieu

Hi everyone,

I am still having a hard time to understand the difference between concurrency and asynchronous.
I have asked the question about how we can achieve highly concurrency in elixir here and all the answers really helps a lot.
But, I recently view the presentation about modern java non-blocking library like Reactor or RxJava. I think they are non-blocking java library and helps to use resource more efficiently and asynchronously.
My understanding about reactor is as follow:

  • They also use 1 thread for each cpu cores
  • Use event loop mechanism, ie. when there’s a request come in, they do the book keeping (register request and its callback) and move it to the waiting queue so that the system can continue serving more request. When there’s result comeback then the callback is put in the event queue and processed by event loop.

So basically I think it was also like elixir where one scheduler thread run processes when needed ?

So I think reactor is also highly concurrent if the “task” is IO-bound ? And in this case, elixir and java reactive library is the same ?

And elixir only prove more concurrency when the “task” is cpu-bound ? I am still not sure how the event loop will behave in that situation because I think the code in the callback should be very quick to avoid blocking the entire system.

Another question is that library like reactor support the reactive streams specification. I also read in one of the blog post saying that otp which is based on actor model is also provide built-in support for reactive streams. Can you help to explain that ?

I would appreciate your feedback on this questions. Thank you so much?

Showing Posts 1 to 1

ityonemo

ityonemo

I have not used java in a long time. If java reactor works the way you say it does, it is in many ways similar to elixir. But I think the difference is this: Elixir is designed from the bottom up to work with its “event loop”. If you write a long function in elixir, the system knows exactly where to interrupt this function and move on to work on another function. Can you say the same for Java? Can you say with confidence that whatever mechanism reactor uses to decide when to take control away from one task plays nicely with the entire JVM ecosystem?

OTP is not based on the actor model, but it looks a lot like the actor model. It’s so close that it’s often “good enough” to think about it that way. But it’s important to remember, the actor model was designed as a way to organize your code, and erlang processes were designed as a way to organize your failure domains. These are different in very important ways. If you try too hard to follow the traditional actor model in your BEAM program design, you are very likely to wind up with bottlenecks. If you don’t care about bottlenecks (which you don’t need to for some tasks), then that might be okay too (I watched a fantastic talk by Laura Castro where she designed a very actor- heavy system, and you know what, it was totally fine, for her purposes). There aren’t any absolute answers. Sometimes the JVM is going to be better than the BEAM, but I personally wouldn’t want to spend my time coding in the JVM.

Maybe one way to put it is this: I write code in the BEAM because I care about my customers and I like to sleep soundly at night =D. There is no way to measure that.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews