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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>We’ve recently started needing durable background jobs and we seem to be taking an approach I haven’t really seen discussed. Rather than relying on a job queuing library we use straight OTP and rely on application state to handle durability.</p>
<p>What I mean by “rely on application state to handle durability” is rather than having some sort of queuing system like a “jobs” table or a separate Redis server we just query our data and depending on the state of the data we can determine if we need to start a job.</p>
<p>An example of this is we need to register a webhook with a 3rd party API for our application to work. When we register the webhook we receive a webhook id back from the 3rd party API and store that in our application. Suffice it to say it’s really important that these webhooks get registered. We need to be able to handle failure states (retries) and recover from system restarts (durability).</p>
<p>When we run the process to create an account we start a “worker” GenServer that is responsible for registering the webhook. If all goes well the webhook is registered, we store the id and the GenServer stops. If things don’t go to plan we try again after a period of time using <code>Process.send_after/4</code>.</p>
<p>When the system restarts we have a “booter” GenServer that is responsible for finding all accounts that don’t have a webhook id and starting worker processes to get those accounts taken care of.</p>
<p>Using this methodology we stay completely within the ecosystem of OTP and our application. We don’t have to introduce any new dependencies or worry about our job queue and application state getting out of whack. OTP has all the tools necessary to make scheduling, retries, etc. a breeze.</p>
<p>Curious to hear people’s thoughts on this approach. I’m sure it doesn’t take care of all use cases but it’s worked well for us thus far.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="130515" 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/background-job-queues-when-to-use-when-not-to-use-which-one-to-use/20436/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-130515" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="130515"
                     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 #21"></div>
  </section>
</div>
    <div class="postbit" id="130519" data-post-id="130519">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>If I understand correctly this approach sounds a lot like what Honeydew ecto_poll queues do. They store both the fact that job is needed, and its state in a couple of columns added to your existing application tables. This way jobs only run if the transaction they are created in completes successfully, and should be just as durable in the sense of restart resiliency, failure retries, and a guarantee that only one worker is trying to run a job at a given 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="130519" 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/background-job-queues-when-to-use-when-not-to-use-which-one-to-use/20436/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-130519" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="130519"
                     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 #22"></div>
  </section>
</div>
    <div class="postbit" id="130768" data-post-id="130768">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I don’t believe so. Our workers are started explicitly rather than through a polling mechanism. The only time the database is polled is by the “booter” process when the application starts. We also don’t keep any job specific data in our database.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="130768" 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/background-job-queues-when-to-use-when-not-to-use-which-one-to-use/20436/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-130768" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="130768"
                     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 #23"></div>
  </section>
</div>
    <div class="postbit" id="131130" data-post-id="131130">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Just wanted to add that I recently released <code>rabbit </code> - a library for building applications using RabbitMQ. Which of course can be used for background job processing. Permits a lot of flexibility in how you want to setup your producers and consumers. Basically allows you to “build your own job framework”.</p>
<p>So far - its managed to reach the “typical” max performance that a single queue in no ack mode with a single consumer will achieve - about 50k/second. Meaning the bottleneck ends up being RabbitMQ itself.</p>
<p>Always open to contributions.</p>
<ul>
<li><a href="https://github.com/nsweeting/rabbit" rel="noopener nofollow ugc">Github</a></li>
<li><a href="https://hex.pm/packages/rabbit" rel="nofollow">Hex</a></li>
<li><a href="https://hexdocs.pm/rabbit" rel="noopener nofollow ugc">Documentation</a></li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="131130" 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/background-job-queues-when-to-use-when-not-to-use-which-one-to-use/20436/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-131130" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="131130"
                     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 #24"></div>
  </section>
</div>
    <div class="postbit" id="131761" data-post-id="131761">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="axelson" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/axelson/120/26351_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  axelson
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Scenic Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I just want to add to this thread that <a class="mention" href="/u/sorentwo" rel="nofollow">@sorentwo</a> recently released <a href="https://forum.elixirforum.com/t/oban-reliable-and-observable-job-processing/22449" class="inline-onebox" rel="nofollow">Oban - Reliable and Observable Job Processing</a> which looks to be a great addition and I’m hoping to try it out in depth soon.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="131761" 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/background-job-queues-when-to-use-when-not-to-use-which-one-to-use/20436/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-131761" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="131761"
                     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>