leighshepperson

leighshepperson

Flow and partitions

This is probably a basic question about flows, but:

At the partition stage, where you can specify the number of partitions, does this number only relate to physical processors and nodes?

Or, if the number of partitions exceeds this value, does it also partition against otp processes?

At the reducer stage, you should be able to run the computations in parallel as much as possible right? So it would be an advantage to create as many partitions as possible (supposing you are not copying too much data around)?

Most Liked

imetallica

imetallica

You can set as an argument the number of the partitions you want. By default, Elixir will use the same number of processors on the machine and it’s not designed to work in a distributed fashion (https://hexdocs.pm/flow/Flow.html#from_enumerables/2-options).

Flow.from_enumerable([1, 2, 3], stages: 3) # To use 3 processes

If I’m not mistaken, the reducer stage is where you join everything together. So, the computations are run in parallel on the mapping stage, not on the reducer stage. So, every time you call Flow.partition/2, new processes will be used by that computations. For example:

[1, 2, 3]
|> Flow.from_enumerable()
|> Flow.map(fn x -> x + 1 end) # [2, 3, 4]
|> Flow.partition() # A new group of processes will be spawned here.
|> Flow.map(fn x -> x * 2 end) # [4, 6, 8]
|> Flow.partition() # A new group of processes will be spawned here.
|> Flow.reduce(fn -> 0 end, fn x, acc -> x + acc end)

$> 18

imetallica

imetallica

Be in mind that Flow does not work in a distributed way - it only works on a single node.

I’m not sure if I understand your question. Can you elaborate more what you want to achieve?

quda

quda

Sorry, I have to revive this old topic because I have new… needs about Flow.
I know that at the level of 2017 Flow didn’t work in a distributed way.
Now is it possible to make it run on multiple nodes ? In such way to distribute partitions among nodes ?
Is there an alternative for distributed MapReduce in Elixir ?

Where Next?

Popular in Questions Top

yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement