<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi, </div><div> First of all thank you to Jesper and Troben.</div><div><br></div><div><div>On 03/ago/2016, at 14:26, Jesper Louis Andersen <<a href="mailto:jesper.louis.andersen@gmail.com">jesper.louis.andersen@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 28, 2016 at 7:47 AM, Giovanni Giorgi <span dir="ltr"><<a href="mailto:jj@gioorgi.com" target="_blank">jj@gioorgi.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">Now the question is: Is a correct approach?</blockquote></div><br></div><div class="gmail_extra">The key observation is: "How do you want to handle error in the processes?"<br></div></div></blockquote>[snip]<br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra">You could simply run the tickers as Torben suggests and then spawn_link them under the main process. </div></div></blockquote>...</div><div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra">You could also use an asymmetric solution: spawn_monitor the tickers and have the tickers monitor the main process. This allows you to handle the case where you want to restart a crashing ticker for instance, but you have to write the logic yourself.<br></div></div></blockquote><div><br></div><div>In my first implementation I am using spawn_monitor because I want to know if some process die, but I do not want to tear down the entire tree for a stupid network error.</div><div>I am also thinking to get a stronger child process which will crash only for a very bad error (i.e. out of memory or other important logic error).</div><div>I think I need to implement a supervisor-like behavior for the server watching the small processes</div><div><br></div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">In general, spawning processes without knowing where they are only works for processes which are guaranteed to terminate. Otherwise, you end up with process leaks.<br></div></div></blockquote>I got it.</div><div><br></div><div>By the way I am always amaze by how the Erlang language seems like a domain language, because the use of a bunch of right atom give me the freedom to model a problem in an easy to read fashion.</div><div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">The final solution is to use a supervision tree: have a main_sup with children MainProcess and TickerPool, the latter being a simple_one_for_one supervisor. Each ticker is added into the TickerPool with supervisor:start_child. It is the the most complex solution, but it has an advantage over the simpler methods: it encodes a *policy* in the supervisors for handling failure modes. That is, you can tolerate some tickers dying, but not too many before trying to restart larger parts of the system.<br><br></div><div class="gmail_extra">So the TL;DR is to think about the failure mode of the application and write it accordingly.<br></div><div class="gmail_extra"><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">J.</div>
</div></div>
</blockquote></div><br><div>
<div style="color: rgb(0, 0, 0); font-family: Optima; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="color: rgb(0, 0, 0); font-family: Optima; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="color: rgb(0, 0, 0); font-family: Optima; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="font-family: Helvetica; ">--</div></div><div>Giovanni Giorgi</div><div><a href="mailto:jj@gioorgi.com">jj@gioorgi.com</a></div><div><br></div></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br></body></html>