1

Suppose you want to send a big list (1_000_000 entries for example) to a different process in Erlang / Elixir.

  • Does send block until the data of the whole list is sent, or is that somehow done asynchronously by the Erlang VM?
  • Is simply sending the list a bad practice? What are the alternatives?
Luca Fülbier
  • 2,641
  • 1
  • 26
  • 43
  • 3
    Dont think it's a good idea. Check this question -> http://stackoverflow.com/questions/5394566/erlang-sending-big-message-performance – NoDisplayName Jan 26 '17 at 09:59
  • 1
    You could possibly use [ets](http://erlang.org/doc/man/ets.html) to store your data in and pass references to the table(s) around. – nietaki Jan 26 '17 at 12:23

1 Answers1

3
  • Yes and no. Copying of huge structure doesn't block receiver but sender. See my answer to a similar question.
  • Yes, it is bad practice if you do it regularly. Alternatively:
    1. Refactor your code so you could partition data to different processes.
    2. Store data in ets. (It's not a magic bullet, you still copy data in and out of ets but it depends on your access pattern.)
    3. Store data as binary.

It depends on what do you do. You should not have a big heap in a process so probably you should refactor your code.

Community
  • 1
  • 1
Hynek -Pichi- Vychodil
  • 26,174
  • 5
  • 52
  • 73
  • I was just asking out of curiosity, as i am currently faced with communicating a big list of data between two threads in Java. Concurrency in Java is a real pain, so i was interested in how i would do the same thing in Elixir which uses message passing. If i had to solve the same thing in Elixir i would probably use an ets table or a separate process that provides a list-like access pattern, like you said. – Luca Fülbier Jan 26 '17 at 13:05
  • 1
    @LucaFülbier: Keep in mind that even you will use proxy process with list-like API you still could face long GC pauses due big heap size. Generation nature of Erlang's GC would help but from time to time you would see a long pause in this process response similar to Java behavior. – Hynek -Pichi- Vychodil Jan 26 '17 at 14:49