<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="87829" data-post-id="87829">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dom" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dom/120/9313_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dom
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Phillipp" data-post="8" data-topic="15083">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/phillipp/48/10625_2.png" class="avatar"> Phillipp:</div>
<blockquote>
<p>I already had cases where the GenServers that were monitored by my single Registry blew up the Registry due to fast restarting or whatever.</p>
</blockquote>
</aside>
<p>Are you sure <em>the supervisor</em> of the registry didn’t crash, bringing down the registry together with it?</p>
<p>If you don’t trust Registry, you probably shouldn’t trust DynamicSupervisor either, they’re written by the same folks and do similar work monitoring and tracking processes.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="87829" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/process-communication-in-a-dynamic-supervision-setup/15083/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-87829" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="87829"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="87842" data-post-id="87842">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Phillipp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Phillipp/120/10625_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Phillipp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I can’t tell what happened exactly.</p>
<p>The setup in that project is like this:</p>
<pre><code>Supervisor:
-- Registry
-- DynamicSupervisor
------ DynamicSupervisor
---------- GenServer
---------- GenServer
---------- GenServer
------ DynamicSupervisor
---------- GenServer
---------- GenServer
---------- GenServer
...
</code></pre>
<p>I had cases where the Supervisor supervising the GenServers died and restarted but I cannot remember that the top level supervisor ever died.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="87842" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/process-communication-in-a-dynamic-supervision-setup/15083/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-87842" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="87842"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="87844" data-post-id="87844">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tcoopman" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tcoopman/120/8112_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tcoopman
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Phillipp" data-post="13" data-topic="15083">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/phillipp/48/10625_2.png" class="avatar"> Phillipp:</div>
<blockquote>
<p>The setup in that project is like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Supervisor:
-- Registry
-- DynamicSupervisor
</code></pre>
</blockquote>
</aside>
<p>What was your restart policy for the <code>Supervisor</code>? If it was <code>one_for_all</code> than that’s exactly the behaviour you would be seeing. Everything your <code>DynamicSupervisor</code> would crash, everything under the <code>Supervisor</code> would be restarted.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="87844" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/process-communication-in-a-dynamic-supervision-setup/15083/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-87844" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="87844"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="87845" data-post-id="87845">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Phillipp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Phillipp/120/10625_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Phillipp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/tcoopman" rel="nofollow">@tcoopman</a> A normal <code>one_for_one</code>. It didn’t happen recently tho.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="87845" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/process-communication-in-a-dynamic-supervision-setup/15083/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-87845" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="87845"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="87899" data-post-id="87899">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Phillipp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Phillipp/120/10625_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Phillipp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>So, I played around a bit and created an example add.</p>
<p>I used a single Registry which seems to work fine. Code can be found here:<br>
<a href="https://github.com/PhillippOhlandt/dynamic_supervision_communication" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/PhillippOhlandt/dynamic_supervision_communication</a></p>
<p>For now, I just added the mechanism to start a new unit which then starts a service and two worker processes. Gonna add unit listing/deletion/state retrieval too. In the mean time, feel free to look over the code and suggest things that could be improved (concept wise).</p>
<p>Here is an example console output:</p>
<pre><code>iex(82)&gt; MyApp.add_unit "Unit 1"
{:ok, #PID&lt;0.1344.0&gt;}
iex(83)&gt; Unit 1/:worker_two got work to do
Unit 1: Message from :worker_two: I don't really wanna do the work today!
Unit 1/:worker_two got work to do
Unit 1: Message from :worker_two: I don't really wanna do the work today!
Unit 1/:worker_one got work to do
Unit 1: Message from :worker_one: I don't really wanna do the work today!
Unit 1/:worker_one got work to do
Unit 1: Message from :worker_one: I don't really wanna do the work today!

nil
iex(84)&gt; MyApp.add_unit "Unit 2"
{:ok, #PID&lt;0.1351.0&gt;}
iex(85)&gt; Unit 1/:worker_one got work to do
Unit 1: Message from :worker_one: I don't really wanna do the work today!
Unit 2/:worker_one got work to do
Unit 2: Message from :worker_one: I don't really wanna do the work today!
Unit 1/:worker_one got work to do
Unit 1: Message from :worker_one: I don't really wanna do the work today!
Unit 2/:worker_two got work to do
Unit 2: Message from :worker_two: I don't really wanna do the work today!
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="87899" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/process-communication-in-a-dynamic-supervision-setup/15083/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-87899" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="87899"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
    <div class="postbit" id="87939" data-post-id="87939">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="xlphs" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/xlphs/120/12168_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  xlphs
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I usually name my GenServer like <code>{:global, {:whatever_name, unique_id}} </code>, then at runtime, look up pid with <code>GenServer.whereis/1</code>, do that every time you need to send a message, just in case the process was restarted in between. If only one instance will be running, use <code>__MODULE__</code> works too and saves the lookup.</p>
<p>I doubt you need Registry for this.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="87939" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/process-communication-in-a-dynamic-supervision-setup/15083/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-87939" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="87939"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="89493" data-post-id="89493">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Phillipp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Phillipp/120/10625_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Phillipp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Got another feature I would like to have.</p>
<p>In my setup, given I have started some units. Now I want to “label” them.<br>
Lets say I have Unit 1, 2 and 3. Unit 1 and 2 get the label/value “foo/bar” and “foo/baz” and Unit 3 gets only “bla/blub”.</p>
<p>Now I want to reach out to all Units with the label/value “foo/bar” which in this case are Unit 1 and 2.</p>
<p>There are two ways of doing this which have their own tradeoffs:</p>
<ol>
<li>
<p>Using another Registry with duplicated keys. When I send a unit to register under a certain label/value, it registers itself in that new Registry. The good thing is, if that unit dies, the Registry will remove the entries. The bad thing is, if the unit dies and restarts, the label information are lost. I would need to store them somewhere else to recover them.</p>
</li>
<li>
<p>Using a simple GenServer to store a map of label/value entries and their connected “unit names” (not pids). The good thing is, if a unit gets restarted, I don’t lose the label information. The bad thing is, the reference map could get outdated and inconsistent.</p>
</li>
</ol>
<p>Which way would you prefer?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="89493" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/process-communication-in-a-dynamic-supervision-setup/15083/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-89493" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="89493"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="89928" data-post-id="89928">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="xlphs" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/xlphs/120/12168_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  xlphs
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I think you are looking for <a href="https://github.com/uwiger/gproc" class="inline-onebox" rel="noopener nofollow ugc">GitHub - uwiger/gproc: Extended process registry for Erlang · GitHub</a> , one of its feature is “Register a process under several aliases”</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="89928" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/process-communication-in-a-dynamic-supervision-setup/15083/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-89928" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="89928"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="89929" data-post-id="89929">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Phillipp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Phillipp/120/10625_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Phillipp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="xlphs" data-post="19" data-topic="15083" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/xlphs/48/12168_2.png" class="avatar"> xlphs:</div>
<blockquote>
<p>I think you are looking for <a href="https://github.com/uwiger/gproc" class="inline-onebox" rel="noopener nofollow ugc">GitHub - uwiger/gproc: Extended process registry for Erlang · GitHub</a> , one of its feature is “Register a process under several aliases”</p>
</blockquote>
</aside>
<p>I am sure I will run into problem 1 from above too.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="89929" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/process-communication-in-a-dynamic-supervision-setup/15083/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-89929" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="89929"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #19"></div>
  </section>
</div>
    <div class="postbit" id="89930" data-post-id="89930">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tty" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tty
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>When you start GenServer with {:global, term()} you can only have one instance per cluster for a specific term(). Starting with {atom(), node()} would have one per node. Different runtime characteristics for different use case.</p>
<p>With {:global, term()} you could use GenServer:call/cast( {:global, term()}, request ) instead of doing a whereis/1 each time. GenServer would route the request to the correct node for you.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="89930" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/process-communication-in-a-dynamic-supervision-setup/15083/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-89930" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="89930"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/15083/load_more?page=3">Load more posts (3 remaining)</a>
</div></template></turbo-stream>