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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="ndrean" data-post="1" data-topic="48748">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/48/36680_2.png" class="avatar"> ndrean:</div>
<blockquote>
<p><code>def handle_call({:new, user}, _from,_state) do</code></p>
</blockquote>
</aside>
<p>A general observation: if you’re ignoring the GenServer’s state in every handler, you probably don’t need a GenServer. For instance, <code>save_with_call</code> could be simplified to:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def save_with_call(user) do
  Phoenix.PubSub.broadcast_from(MyApp.PubSub, self(), @topic, {:perform_new, user})
end
</code></pre>
<p>As a bonus, this approach doesn’t have a single process (the GenServer) forcing everything to happen one-at-a-time.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="254933" 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/unknown-registry-genserver/48748/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-254933" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="254933"
                     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="254939" data-post-id="254939">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ndrean" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/120/36680_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ndrean
                      <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>OK, good point, in fact, I really wondered, indeed, but how do I respond to <code>:perform_new</code> if not from a Genserver? As you say, I only use the messaging part.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="254939" 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/unknown-registry-genserver/48748/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-254939" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="254939"
                     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="254942" data-post-id="254942">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You can have a GenServer (or any interested process) subscribe to and handle the messages, or a pool of them with a pool manager dispatching the messages, but you don’t need to send the messages from the GenServer if that’s all that <code>save_with_*</code> is doing. You can pubsub those messages from any process and your <code>MyApp.Repo</code> servers will subscribe to that topic. Then you’ll avoid routing new messages through the same process that wants to receive them, which significantly reduces the work load on each one and increases their throughput receiving the messages</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="254942" 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/unknown-registry-genserver/48748/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-254942" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="254942"
                     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="254947" data-post-id="254947">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ndrean" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/120/36680_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ndrean
                      <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>Firstly apologize, just a beginner with Elixir. Then yes I believe I started with this, not using <code>GenServer.call</code>. This relieves a bit of pressure but I may still need the GenServer behaviour. Nodes subscribe to this pubusub topic. Nodes also listen to <code>:net_kernel.monitor_nodes</code> events, and broadcast on a <code>:nodeup</code>  event. I need to capture the message the nodes broadcasts and do something, so I don’t know how to do this is not using a <code>handle_info</code> matcher offered by the server</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="254947" 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/unknown-registry-genserver/48748/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-254947" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="254947"
                     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="254948" data-post-id="254948">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ndrean" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/120/36680_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ndrean
                      <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>Yes, I don’t need this <code>handle_call</code> indeed.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="254948" 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/unknown-registry-genserver/48748/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-254948" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="254948"
                     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="254955" data-post-id="254955">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>No need to apologize! OTP takes time to learn but it’s a rewarding process.</p>
<aside class="quote no-group" data-username="ndrean" data-post="15" data-topic="48748">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/48/36680_2.png" class="avatar"> ndrean:</div>
<blockquote>
<p>This relieves a bit of pressure but I may still need the GenServer behaviour. Nodes subscribe to this pubusub topic.</p>
</blockquote>
</aside>
<p>Yes exactly, you can have a process or pool of processes on each node subscribing to the pubsub messages, even though they can be broadcasted by any caller in the cluster.</p>
<aside class="quote no-group" data-username="ndrean" data-post="15" data-topic="48748">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/48/36680_2.png" class="avatar"> ndrean:</div>
<blockquote>
<p>Nodes also listen to <code>:net_kernel.monitor_nodes</code> events, and broadcast on a <code>:nodeup</code> event. I need to capture the message the nodes broadcasts and do something, so I don’t know how to do this is not using a <code>handle_info</code> matcher offered by the server</p>
</blockquote>
</aside>
<p>You will also need a long running process to listen for these <code>:nodeup</code> events and rebroadcast them, and any interested process can subscribe to the topic. You should probably have a <code>NodeListener</code> with the sole responsibility to handle and rebroadcast these events. All of the messages we’ve discussed so far can be handled by the <code>handle_info/2</code> callback of the GenServer behaviour.</p>
<aside class="quote no-group" data-username="ndrean" data-post="16" data-topic="48748" 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/ndrean/48/36680_2.png" class="avatar"> ndrean:</div>
<blockquote>
<p>Yes, I don’t need this <code>handle_call</code> indeed.</p>
</blockquote>
</aside>
<p>You only need to <code>call</code> a GenServer if it holds some state (data, connection, etc.) or performs some computation and you need the results returned. It’s always synchronous. If the calling process can do the work itself then it probably should unless you need to offload it for async behavior or error isolation, in which case you might consider spawning a <code>Task</code> instead of sending it to a single GenServer.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="254955" 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/unknown-registry-genserver/48748/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-254955" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="254955"
                     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="254957" data-post-id="254957">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>A basic implementation of what I think you’re looking for</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyApp.NodeListener do
  use GenServer
  require Logger

  def start_link(arg), do: GenServer.start_link(__MODULE__, arg, name: __MODULE__)

  def init(_arg) do
    :net_kernel.monitor_nodes(true)
    {:ok, []}
  end

  def handle_info({:nodeup, _} = payload, state) do
    Phoenix.PubSub.broadcast!(MyApp.PubSub, "cluster", payload)
    {:noreply, state}
  end

  def handle_info(_, state), do: {:noreply, state}
end

defmodule MyApp.Repo do
  use GenServer
  require Logger

  def start_link(arg), do: GenServer.start_link(__MODULE__, arg, name: __MODULE__)

  def init(_arg) do
    Phoenix.PubSub.subscribe(MyApp.PubSub, "cluster")
    Phoenix.PubSub.subscribe(MyApp.PubSub, "users")
    {:ok, []}
  end

  def handle_info({:new, user}, state) do
    Logger.info("Repo (#{inspect(node())}) received user: #{inspect(user)}")
    {:noreply, state}
  end

  def handle_info({:nodeup, _} = msg, state) do
    Logger.info("Repo (#{inspect(node())}) received #{inspect(msg)}")
    {:noreply, state}
  end
end

defmodule MyApp.Users do
  def save(user) do
    Phoenix.PubSub.broadcast!(MyApp.PubSub, "users", {:new, user})
  end
end

defmodule MyApp.Application do
  use Application

  def start(_type, _args) do
    children = [
      {Phoenix.PubSub, name: MyApp.PubSub},
      MyApp.NodeListener,
      MyApp.Repo
    ]
    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

$ iex --name a@127.0.0.1 -S mix

# in another terminal
$ iex --name b@127.0.0.1 -S mix

iex(a@127.0.0.1)1&gt; Node.connect(:"b@127.0.0.1")
true

19:43:49.050 [info]  Repo (:"a@127.0.0.1") received {:nodeup, :"b@127.0.0.1"}

19:43:49.050 [info]  Repo (:"b@127.0.0.1") received {:nodeup, :"a@127.0.0.1"}

iex(b@127.0.0.1)1&gt; MyApp.Users.save(1)
:ok

19:44:10.905 [info]  Repo (:"b@127.0.0.1") received user: 1

19:44:10.905 [info]  Repo (:"a@127.0.0.1") received user: 1
</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="254957" 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/unknown-registry-genserver/48748/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-254957" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="254957"
                     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="255015" data-post-id="255015">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ndrean" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/120/36680_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ndrean
                      <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>Thanks, I refactored with your comments and challenged myself. Quite a few takeaways there. First  <a href="https://elixir-lang.org/getting-started/mix-otp/genserver.html#call-cast-or-info" rel="nofollow">about backpressure</a>. Not sure to understand this term? Is this related to filling up the server’s mailbox? So you mentioned a pool of servers to push it a bit further. I will probably keep this for later as I imagine you may need libraries like <a href="https://elixirschool.com/en/lessons/misc/poolboy" rel="noopener nofollow ugc">Poolboy</a> for this.<br>
Then besides code readability or “testability”, does segregation bring better performance in terms of robustness on load? For example:</p>
<ul>
<li>two PubSub topic is better than one? (I could not extract a PID to check).</li>
<li>designing two servers instead of one relieves partly the load on the mailbox I imagine.</li>
<li>also about error handling. Should there be a rescue?<br>
I ask these questions because concurrency between processes is a delicate topic, and <a href="https://hexdocs.pm/gen_stage/GenStage.html#module-usage-guidelines" rel="noopener nofollow ugc">reading about the usage guidelines of GenStage</a>, again they speak about “backpressure”. Maybe some book you may recommend?</li>
</ul>
<p>Finally, as a side comment, I noticed the catch-all clause you introduced: <code>handle_info(_, state), do: {:noreply, state}</code>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="255015" 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/unknown-registry-genserver/48748/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-255015" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="255015"
                     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="255017" data-post-id="255017">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="ndrean" data-post="19" data-topic="48748">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/48/36680_2.png" class="avatar"> ndrean:</div>
<blockquote>
<p>First <a href="https://elixir-lang.org/getting-started/mix-otp/genserver.html#call-cast-or-info" rel="nofollow">about backpressure</a>.</p>
</blockquote>
</aside>
<p>Backpressure describes the act of not accepting more work before having completed previous/existing work. This allows you to prevent parts of your system from being overloaded, because at best you cannot sent them more work than they can handle. This will push work to queue up in known places where you can then deal with it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="255017" 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/unknown-registry-genserver/48748/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-255017" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="255017"
                     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="255022" data-post-id="255022">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="ndrean" data-post="19" data-topic="48748">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/48/36680_2.png" class="avatar"> ndrean:</div>
<blockquote>
<p>So you mentioned a pool of servers to push it a bit further. I will probably keep this for later as I imagine you may need libraries like <a href="https://elixirschool.com/en/lessons/misc/poolboy" rel="noopener nofollow ugc">Poolboy</a> for this.</p>
</blockquote>
</aside>
<p>I think you would also be able to implement something simple with the <code>PartitionSupervisor</code>  coming in 1.14. You would have to do some hashing to make sure the messages are not duped on multiple server partitions.</p>
<aside class="quote no-group" data-username="ndrean" data-post="19" data-topic="48748">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/48/36680_2.png" class="avatar"> ndrean:</div>
<blockquote>
<p>two PubSub topic is better than one? (I could not extract a PID to check).</p>
</blockquote>
</aside>
<p>To me, <code>node up</code> and <code>new user</code> are separate topics, so by splitting them you can have other processes subscribe to one or the other in the future without coupling them together</p>
<aside class="quote no-group" data-username="ndrean" data-post="19" data-topic="48748">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/48/36680_2.png" class="avatar"> ndrean:</div>
<blockquote>
<p>designing two servers instead of one relieves partly the load on the mailbox I imagine.</p>
</blockquote>
</aside>
<p>I put the <code>NodeListener</code> as its own process precisely because it has one responsibility. It reduces the load on <code>Repo</code> because <code>Repo</code> doesn’t care about <code>nodedown</code> (at least that’s what I took away from what you said). And if other processes may be interested in cluster membership, the <code>NodeListener</code> can be the hub for those events for the whole node, without needing multiple processes to be subscribing to <code>net_kernel.monitor_nodes</code>.</p>
<aside class="quote no-group" data-username="ndrean" data-post="19" data-topic="48748">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/48/36680_2.png" class="avatar"> ndrean:</div>
<blockquote>
<p>also about error handling. Should there be a rescue?</p>
</blockquote>
</aside>
<p>If there is an error that you expect might happen and you have a way to recover from it, then I think you handle it explicitly with pattern matching. If there is a real exception with no recovery then “let it crash”, and the supervisor will restart your process at a known good state.</p>
<aside class="quote no-group" data-username="ndrean" data-post="19" data-topic="48748">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/48/36680_2.png" class="avatar"> ndrean:</div>
<blockquote>
<p>Finally, as a side comment, I noticed the catch-all clause you introduced: <code>handle_info(_, state), do: {:noreply, state}</code>.</p>
</blockquote>
</aside>
<p>I added this because you said</p>
<aside class="quote no-group" data-username="ndrean" data-post="15" data-topic="48748">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ndrean/48/36680_2.png" class="avatar"> ndrean:</div>
<blockquote>
<p>Nodes also listen to <code>:net_kernel.monitor_nodes</code> events, and broadcast on a <code>:nodeup</code> event.</p>
</blockquote>
</aside>
<p>So I assumed you were only interested in <code>:nodeup</code>, not <code>:nodedown</code>. If you monitor nodes you will receive both, so I discarded the <code>:nodedown</code> messages. Maybe that was a wrong assumption <img src="https://forum.elixirforum.com/images/emoji/apple/smile.png?v=15" title=":smile:" class="emoji" alt=":smile:" 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="255022" 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/unknown-registry-genserver/48748/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-255022" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="255022"
                     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/48748/load_more?page=3">Load more posts (4 remaining)</a>
</div></template></turbo-stream>