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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="benwilson512" data-post="9" data-topic="20188">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/48/1457_2.png" class="avatar"> benwilson512:</div>
<blockquote>
<p>you can use Registry to broadcast,</p>
</blockquote>
</aside>
<p>nice! I just saw <a href="https://hexdocs.pm/elixir/master/Registry.html#dispatch/4" rel="noopener nofollow ugc">Registry.dispatch</a>, is it this you were referring to?</p>
<p>I’m used to use Registry with <code>:via</code>. I didn’t see this function <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="116174" 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/manage-state-in-elixir/20188/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-116174" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="116174"
                     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="116179" data-post-id="116179">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Fl4m3Ph03n1x" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Fl4m3Ph03n1x/120/11709_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Fl4m3Ph03n1x
                    <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="benwilson512" data-post="9" data-topic="20188">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/48/1457_2.png" class="avatar"> benwilson512:</div>
<blockquote>
<p>How would the process get a command if not by receiving a message? Notably if they’re inside a registry you don’t also need <code>pg2</code> , you can use Registry to broadcast, there are examples in the registry docs.</p>
</blockquote>
</aside>
<p>Good question. I actually don’t care about the response. I only care that I made the request. So I won’t be waiting for anything.<br>
I am also using the Registry in a preliminary solution attempt, but thanks for pointing out!</p>
<aside class="quote no-group quote-modified" data-username="gregvaughn" data-post="10" data-topic="20188">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/48/954_2.png" class="avatar"> gregvaughn:</div>
<blockquote>
<p>The same thing that happens when any other BEAM process dies: it depends on what supervisor it has. The Registry also monitors the process and we de-list a dead process. But the supervisor can restart the process and re-register the new instance with the Registry.</p>
</blockquote>
</aside>
<p>Now this is interesting to me. I know Registry removes dead processes, which is great, but if that is all it does, then overtime time (as some processes eventually fail) I will end up with an empty Registry.</p>
<p>You mentioned int depends on which supervisor it is using. Great news for me. Can I tell this supervisor to create a new <code>gun</code> connection to replace the dead one? (By passing a function or something?)</p>
<p>I couldn’t find documentation about this.</p>
<aside class="quote no-group" data-username="peerreynders" data-post="11" data-topic="20188">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/48/5826_2.png" class="avatar"> peerreynders:</div>
<blockquote>
<p>That being said having 10000 processes pounding on one, single process can still yield all the disadvantages of “being shared” (singleness) in the form of a bottleneck - so a single process isn’t necessarily a good replacement for a single ETS table (depending on the circumstances of course).</p>
</blockquote>
</aside>
<p>This is interesting. Do you mean that the Registry process would actually be <em>the</em> bottleneck here? I have trouble understanding that, since the Registry uses the ETS, which goes back to the first approach I mentioned.</p>
<p>I will attempt to create a better post latter on, with all my questions and without the (horrible) analogy that is confusing everyone.</p>
<aside class="quote no-group" data-username="alvises" data-post="12" data-topic="20188">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alvises/48/2247_2.png" class="avatar"> alvises:</div>
<blockquote>
<p>nice! I just saw <a href="https://hexdocs.pm/elixir/master/Registry.html#dispatch/4" rel="noopener nofollow ugc">Registry.dispatch</a>, is it this you were referring to?</p>
</blockquote>
</aside>
<p>You can do it via dispatch, yes. But the docs go even further:</p>
<p><a href="https://hexdocs.pm/elixir/master/Registry.html#module-using-as-a-pubsub" class="onebox" target="_blank" rel="noopener nofollow ugc">https://hexdocs.pm/elixir/master/Registry.html#module-using-as-a-pubsub</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="116179" 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/manage-state-in-elixir/20188/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-116179" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="116179"
                     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="116180" data-post-id="116180">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="13" data-topic="20188">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>Do you mean that the Registry process would actually be <em>the</em> bottleneck here?</p>
</blockquote>
</aside>
<p>Unlikely as the lookup would be pretty quick. But ETS has been optimized for shared access so any additional layer over top like a guardian process would tend to slow things down - whether that matters is a separate story.</p>
<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="13" data-topic="20188">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>I actually don’t care about the response. I only care that I made the request</p>
</blockquote>
</aside>
<p>You do likely care that a process received your request. Because a <code>send</code> (or <code>cast</code>) to a dead pid  won’t result in an error.</p>
<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="13" data-topic="20188">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>Can I tell this supervisor to create a new <code>gun</code> connection to replace the dead one?</p>
</blockquote>
</aside>
<p>Supervisors simply restart processes the same way they started them the last time - for something a bit smarter (and therefore more fragile) look into <a href="https://github.com/sasa1977/parent" rel="noopener nofollow ugc">parent</a> (<a href="https://github.com/sasa1977/parent/blob/master/RATIONALE.md" rel="noopener nofollow ugc">Rationale</a>).</p>
<p>If for whatever reason a fresh process cannot create it’s own connection it could always get another (named, specialized) process to create it.</p>
<p>Looked at <a href="https://ferd.ca/the-hitchhiker-s-guide-to-the-unexpected.html" rel="noopener nofollow ugc">The Hitchhiker’s Guide to the Unexpected</a> yet?</p>
<blockquote>
<p>Smart systems make stupid mistakes</p>
</blockquote> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="116180" data-batch-url="/posts/batch_likers">
                        2
                      </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/manage-state-in-elixir/20188/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-116180" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="116180"
                     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="116182" data-post-id="116182">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="benwilson512" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/120/1457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  benwilson512
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Craft GraphQL APIs in Elixir with Absinthe</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="13" data-topic="20188">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>Do you mean that the Registry process would actually be <em>the</em> bottleneck here?</p>
</blockquote>
</aside>
<p>There is no single Registry process. Registry is very well optimized having been derived from Phoenix pubsub. It is not likely to be your bottleneck.</p>
<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="13" data-topic="20188">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>Good question. I actually don’t care about the response. I only care that I made the request.</p>
</blockquote>
</aside>
<p>Sending a message doesn’t require that you get a response.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="116182" data-batch-url="/posts/batch_likers">
                        2
                      </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/manage-state-in-elixir/20188/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-116182" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="116182"
                     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="116190" data-post-id="116190">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="Fl4m3Ph03n1x" data-post="13" data-topic="20188">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<blockquote>
<p>The same thing that happens when any other BEAM process dies: it depends on what supervisor it has. The Registry also monitors the process and we de-list a dead process. But the supervisor can restart the process and re-register the new instance with the Registry.</p>
</blockquote>
<p>You mentioned int depends on which supervisor it is using. Great news for me. Can I tell this supervisor to create a new <code>gun</code> connection to replace the dead one? (By passing a function or something?)</p>
<p>I couldn’t find documentation about this.</p>
</blockquote>
</aside>
<p>I think you missed my point. I’m not talking about the supervisor of the registry (whose job is to keep the registry running), but the supervisor of your gun processes. That supervisor is given a child spec with a <code>restart: :permanent</code> like any other supervisor can receive, and it will restart your process when it dies. During your process’ startup, it can then register itself.</p>
<p>Docs for restart values are here in the Supervisor module <a href="https://hexdocs.pm/elixir/Supervisor.html#module-restart-values-restart" class="inline-onebox" rel="noopener nofollow ugc">Supervisor — Elixir v1.20.2</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="116190" data-batch-url="/posts/batch_likers">
                        2
                      </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/manage-state-in-elixir/20188/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-116190" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="116190"
                     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 #15"></div>
  </section>
</div>
    <div class="postbit" id="117310" data-post-id="117310">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>This still sounds like poolboy to me- unless each connection is to a different endpoint, in which case process registration like other people mentioned here would work better. But if you connect to the same (or just a couple) different endpoints and do not wish to pay upfront the cost of opening 10000 connections, you can do that lazily with poolboy using a <a href="https://github.com/devinus/poolboy/blob/master/README.md#options" rel="noopener nofollow ugc">small size with a large max overflow</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="117310" 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/manage-state-in-elixir/20188/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-117310" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="117310"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>