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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Similar to serverless frameworks/services there is a minimum that you can set, such that you always have a certain number of nodes running.</p>
<p>I also have not used it in production but used it to do some testing of the viability for running some mildly resource intensive tasks. We didn’t end up using it because there was/is not a GCP backend and we didn’t want to add k8s.</p>
<p>We didn’t end up using Oban Pro’s Relay for our particular use case and instead used a Workflow, and PubSub, and then tracked the completion and returns of the workflow steps in the caller and listened for incremental messages on the subscription. Not super elegant, but got the job done of easily allowing multiple people to track the progress.</p>
<p>There’s Oban.Pro.Plugins.DynamicScaler <a href="https://getoban.pro/docs/pro/1.6.0-rc.3/Oban.Pro.Plugins.DynamicScaler.html#module-cloud-modules" class="inline-onebox" rel="noopener nofollow ugc">Oban.Pro.Plugins.DynamicScaler — Oban Pro v1.6.0-rc.3</a> that works with the Oban.Pro.Cloud behaviour.<br>
That might be your best approach for it you use Oban.Pro and the Relay approach.</p>
<p>If you don’t go the Oban Pro route (which I would still suggest. “Boring” architecture is reliable and maintainable architecture) I would steer towards a newer registry approach. I have not used Ra.Registry, but have been following ra for a long time and am very impressed.</p>
<p>I’ve used Horde a great deal, and although it does a great deal very well, once you get into writing your own distribution strategy, you’re going to want a way to reliably test it, and depending on how you do your testing Horde has some disadvantages in that it expects a Horde.DynamicSupervisor’s name to be able to be turned into an atom.<br>
<a href="https://github.com/derekkraan/horde/issues/234" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/derekkraan/horde/issues/234</a></p>
<p>It made my testing a little difficult and because of that I’ve usually tried something else first. It’s still a phenomenal library though. I tried to figure out a way to fix it the issue as well, but I never even got to the point where my fix was working let alone worthy of a pull request upstream.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="364499" 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/distributed-registry-service-discovery-worker-pools-in-non-uniform-clusters/70787/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-364499" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="364499"
                     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="364508" data-post-id="364508">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="felix-starman" data-post="12" data-topic="70787">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/felix-starman/48/18051_2.png" class="avatar"> felix-starman:</div>
<blockquote>
<p>If you don’t go the Oban Pro route (which I would still suggest. “Boring” architecture is reliable and maintainable architecture)</p>
</blockquote>
</aside>
<p>I concur, before I’d even try something like Horde I’d go with Oban Pro.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="364508" 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/distributed-registry-service-discovery-worker-pools-in-non-uniform-clusters/70787/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-364508" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="364508"
                     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="364525" data-post-id="364525">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="jstimps" data-post="11" data-topic="70787">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/48/41062_2.png" class="avatar"> jstimps:</div>
<blockquote>
<p>I think you could get it done with a Ra state machine.</p>
</blockquote>
</aside>
<p>As much as I love fault-tolerant consensus (and you know I do), I don’t think this is really necessary here. If you want exactly-once semantics on the queue you would have to store all of your data in Ra (which will certainly never scale), and process registries are a use-case where I’m not entirely convinced you actually want strong consistency guarantees - because where you <em>really</em> want those guarantees is on the database the processes are writing to. Once the database guarantees correctness the process registry and such only needs good performance (it should be right most of the time), so you don’t really need consensus anymore.</p>
<p>(I have had the misfortune of thinking about this a <em>lot</em> lately.)</p>
<p>But here the data is already stored in Postgres! So if you just put your work queue in Postgres you get transactions over both and you are totally safe correctness-wise (read committed footguns notwithstanding).</p>
<p>Like you could literally just do this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def insert_data(text) do
  %Data{id: id} = Repo.insert!(%Data{text: text})
  Repo.insert! %EmbedJob{data_id: id, lease: nil}
end

def pop_job do
  expired = DateTime.utc_now() |&gt; DateTime.add(-1, :minute)
  Repo.transaction(fn -&gt;
    job = Repo.one!(from j in EmbedJob,
      where: is_nil(j.lease) or j.lease &lt; ^expired,
      order_by: :inserted_at, limit: 1, lock: "for update", preload: :data)
    Repo.update! change(job, %{lease: DateTime.utc_now()})
  end)
end

def worker do
  {:ok, job} = pop_job()
  vector = embed_text(job.data.text)
  Repo.transaction(fn -&gt;
    %Job{} = Repo.one!(from j in EmbedJob, where: j.id == ^job.id, lock: "for update")
    Repo.update! change(job.data, %{vector: vector})
    Repo.delete! job
  end)
end
</code></pre>
<p>And now you don’t need a process registry at all!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="364525" data-batch-url="/posts/batch_likers">
                        3
                      </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/distributed-registry-service-discovery-worker-pools-in-non-uniform-clusters/70787/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-364525" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="364525"
                     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="365309" data-post-id="365309">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Just my two cents, but I came across a number of weird issues with Horde - like processes existing multiple times in the cluster, and many people reporting the same issues… <code>:global</code> ended up being good enough for my use case. Something as foundational as Horde must be rock-solid, otherwise you’ll waste a lot of 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="365309" 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/distributed-registry-service-discovery-worker-pools-in-non-uniform-clusters/70787/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-365309" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="365309"
                     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="365327" data-post-id="365327">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>BTW if anyone is actually doing this, it’s best to use <code>FOR UPDATE SKIP LOCKED</code> to improve concurrency. There are some nice notes <a href="https://blog.sequinstream.com/build-your-own-sqs-or-kafka-with-postgres/" rel="noopener nofollow ugc">in this blog post</a>. I know some of the Sequin guys might be lurking around here, so if you’re reading this: you guys have a great blog! Keep it up <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_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="365327" 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/distributed-registry-service-discovery-worker-pools-in-non-uniform-clusters/70787/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-365327" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="365327"
                     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="365333" data-post-id="365333">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>yep I did that too, worked like a charm. Oban uses that internally 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="365333" 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/distributed-registry-service-discovery-worker-pools-in-non-uniform-clusters/70787/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-365333" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="365333"
                     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="365334" data-post-id="365334">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>That makes sense. To be clear, I believe <code>FOR UPDATE</code> is enough for correctness, <code>SKIP LOCKED</code> would just have better performance because the clients can pop a bit faster since they aren’t blocked by each other for a short 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="365334" 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/distributed-registry-service-discovery-worker-pools-in-non-uniform-clusters/70787/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-365334" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="365334"
                     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="365361" data-post-id="365361">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I mean, we had issues like that too but this was probably due to the CRDTs being what they are. :global is much more predictable if you’re having a solid connection between your nodes (we did not have) that you can rely on. I don’t think it’s meant to be rock-solid the way you’re expecting it to be, there’s always going to be a chance that the same process will register on two nodes, and the idea is that eventually the conflict will be detected and you can handle it, for example.</p>
<p>We did not remove it because it was not working properly, we removed it because the use case we had for it was no longer there. Also, we built everything new on Oban, and the original use case would be too built on Oban if we were to do it all over again.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="365361" 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/distributed-registry-service-discovery-worker-pools-in-non-uniform-clusters/70787/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-365361" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="365361"
                     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="365375" data-post-id="365375">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="hubertlepicki" data-post="19" data-topic="70787">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hubertlepicki/48/6822_2.png" class="avatar"> hubertlepicki:</div>
<blockquote>
<p>the idea is that eventually the conflict will be detected and you can handle it, for example.</p>
</blockquote>
</aside>
<p>The problem was that such conflicts would not be detected, and there is an open bug from 2020 - <a href="https://github.com/derekkraan/horde/issues/207" class="inline-onebox" rel="noopener nofollow ugc">Removing nodes creates multiple processes out of 1 process · Issue #207 · elixir-horde/horde · GitHub</a> - that is still not addressed, nor are any public workarounds available. So it’s a nice idea, but it does not address the common use case of “I want to make sure that all processes are up and (reasonably) unique across the cluster, no matter what happens to cluster topology”.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="365375" 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/distributed-registry-service-discovery-worker-pools-in-non-uniform-clusters/70787/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-365375" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="365375"
                     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="365376" data-post-id="365376">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Ah, I never stumbled upon that issue but mostly because we didn’t have an auto scaler back then. That would bite me a lot these days.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="365376" 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/distributed-registry-service-discovery-worker-pools-in-non-uniform-clusters/70787/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-365376" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="365376"
                     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>