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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="AHBruns" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/AHBruns/120/27529_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  AHBruns
                      <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>Wrt modeling, my intuition would be to model job executions as time windows. Then you can use your existing sliding rate limiting window logic, except instead of asking how many jobs were started in the sliding window, you ask how many jobs had an execution window that overlapped with the sliding window. It seems to me this could be done in a similarly efficient fashion to your existing sliding window implementation.</p>
<p>From an API perspective, I think rate limiting, global limits, and local limits could/should all be unified into a common interface.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="331436" 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/how-to-rate-limit-with-oban/64201/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-331436" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="331436"
                     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="331754" data-post-id="331754">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="AHBruns" data-post="12" data-topic="64201">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ahbruns/48/27529_2.png" class="avatar"> AHBruns:</div>
<blockquote>
<p>except instead of asking how many jobs were started in the sliding window, you ask how many jobs had an execution window that overlapped with the sliding window. It seems to me this could be done in a similarly efficient fashion to your existing sliding window implementation.</p>
</blockquote>
</aside>
<p>It’s certainly possible and something to consider.</p>
<aside class="quote no-group" data-username="AHBruns" data-post="12" data-topic="64201">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ahbruns/48/27529_2.png" class="avatar"> AHBruns:</div>
<blockquote>
<p>From an API perspective, I think rate limiting, global limits, and local limits could/should all be unified into a common interface.</p>
</blockquote>
</aside>
<p>Do you mean internally or a user facing interface?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="331754" 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/how-to-rate-limit-with-oban/64201/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-331754" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="331754"
                     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="331783" data-post-id="331783">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="AHBruns" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/AHBruns/120/27529_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  AHBruns
                      <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="sorentwo" data-post="13" data-topic="64201">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sorentwo/48/37360_2.png" class="avatar"> sorentwo:</div>
<blockquote>
<p>Do you mean internally or a user facing interface?</p>
</blockquote>
</aside>
<p>I mean user facing. I think ultimately, all limits should come down to asking</p>
<ol>
<li>What am I counting? E.g. the number of running jobs on a given queue, the number of jobs that have been started on a given queue, the number of running jobs on a given node, something else?</li>
<li>Over what window am I counting? E.g. a zero length window, a 10 second window, a 2 week window?</li>
<li>What is the max count I’m allowed to hit? Aka the limit.</li>
</ol>
<p>Every one of the existing APIs can be framed in this context.</p>
<ul>
<li>a local limit is counting the number of running jobs on on a given node, it’s counting over a zero length window (aka an instant), and the max count is supplied by the user</li>
<li>a global limit is counting the number of running jobs on on a given queue, it’s counting over a zero length window, and the max count is user supplied</li>
<li>a rate limit is counting the number of jobs started in any given supplied partition (or the queue if none is supplied), it’s counting over a user supplied window length, and the max count is user supplied</li>
</ul>
<p>I have a use case to count the number of running jobs on a given partition over a non zero length window, but I could imagine lots of other useful combinations. Off the top of my head:</p>
<ul>
<li>counting the number of running jobs on a given partition over a zero length window (aka a partition limit rather than a global or local limit).</li>
<li>counting the number of started jobs on a given node over a non-zero length window (aka a per node rate limit)</li>
</ul>
<p>The issue comes up in defining the combinations. E.g. what does measuring the number of jobs started over a zero length window mean? If you model time in discrete ticks, then that’s pretty easy, it’s how many jobs were started in a given tick, but if you model time as continuous, then it’s kind of a meaningless question. Imo, saying that your API is only accurate down to some fundamental tick size is pretty reasonable, and makes everything coherent. In such a world a “zero length window” really means a window that is the length of 1 tick.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="331783" data-batch-url="/posts/batch_likers">
                        5
                      </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/how-to-rate-limit-with-oban/64201/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-331783" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="331783"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-most-liked cat-most-liked" title="One of the top 3 liked posts in this thread!"></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>