Statefull Process

96 views
Skip to first unread message

Kaveh Shahbazian

unread,
Aug 1, 2016, 5:33:30 AM8/1/16
to elixir-lang-talk
(Noob Here) -

Is a statefull process a bottleneck? (Not exactly; because of the Mailbox) Like a `mutex` in more traditional languages?

Narcissus Emi

unread,
Aug 1, 2016, 6:27:23 AM8/1/16
to elixir-lang-talk
What kind of bottleneck are you referring to?
More state just costing more memory.
If you are trying to use process to transfer process state, it might be a bottleneck, since ets can be a better choice.

在 2016年8月1日星期一 UTC+8下午5:33:30,Kaveh Shahbazian写道:

OvermindDL1

unread,
Aug 1, 2016, 10:04:07 AM8/1/16
to elixir-lang-talk
If you mean that it bottlenecks communication with it, yes, the mailbox can kind of be treated like a 'mutex'.  Depending on how you are operating on the data and how it can be referenced then a pool of these managed by a supervisor (or library like poolboy) or operating on multiple messages at once inside the process or even raising it into ETS with a library for operating on the data within ETS can be significantly faster.  However a good bottleneck can help in many cases as well (most I dare say) so it depends on the use-case as to whether you want it or not.

TL;DR: A process generally operates on one message at a time, but there are alternative methods.

Kaveh Shahbazian

unread,
Aug 2, 2016, 3:19:23 AM8/2/16
to elixir-lang-talk
You are right. I'm aware I do not need to worry about blocking - since everything get amortized to any possible detail by EVM. But what I was concerned if the mailbox might get saturated. Thanks for the suggestions!

OvermindDL1

unread,
Aug 2, 2016, 10:30:43 AM8/2/16
to elixir-lang-talk
If the mailbox starts to get overly full then it starts slowing down the senders and they start, basically 'pausing' for very short periods of time to prevent the system slowing down.  This only happens if there are a seriously huge amount of messages in a mailbox for a process though.
Reply all
Reply to author
Forward
0 new messages