# Limit job dispatch calls for parameterized batch job?

**URL:** <https://discuss.hashicorp.com/t/limit-job-dispatch-calls-for-parameterized-batch-job/57258>\
**Category:** Nomad\
**Created:** [August 15, 2023, 2:49am UTC](https://discuss.hashicorp.com/t/limit-job-dispatch-calls-for-parameterized-batch-job/57258 "2023-08-15T02:49:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrismo](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/chrismo/32/31068_2.png) [@chrismo](https://discuss.hashicorp.com/u/chrismo)\
**Post date:** [August 15, 2023, 2:49am UTC](https://discuss.hashicorp.com/t/limit-job-dispatch-calls-for-parameterized-batch-job/57258/1 "2023-08-15T02:49:54Z")

</div>

I accidentally flooded a staging server with a bunch of redundant job dispatch calls. It quickly consumed the available resources on the single client node I had setup and the whole thing fell over. I was able to stop all of the allocations and get it cleaned up, but - what constraints can I put into the job definition to prevent this problem in the future?

Nomad 1.6.1.

---

<div class="post-metadata">

**Author:** ![jrasell](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jrasell/32/5500_2.png) [@jrasell](https://discuss.hashicorp.com/u/jrasell)\
**Post date:** [August 15, 2023, 11:48am UTC](https://discuss.hashicorp.com/t/limit-job-dispatch-calls-for-parameterized-batch-job/57258/2 "2023-08-15T11:48:00Z")

</div>

Hi @chrismo,

There is not currently a way to limit the number of job dispatch calls. In a future version of Nomad, we do expect to have rate limiting available on all API endpoints, which would help in this situation.

Thanks,  
jrasell and the Nomad team

---

<div class="post-metadata">

**Author:** ![chrismo](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/chrismo/32/31068_2.png) [@chrismo](https://discuss.hashicorp.com/u/chrismo)\
**Post date:** [August 15, 2023, 2:37pm UTC](https://discuss.hashicorp.com/t/limit-job-dispatch-calls-for-parameterized-batch-job/57258/3 "2023-08-15T14:37:24Z")

</div>

I presume then the `scaling` stanza wouldn’t apply to a parameterized batch job?

Is there no way for the Nomad server to simply queue or refuse job dispatch calls if there’s no available client resources? If so, that seems strange to me that Nomad would allow a client to be exhausted of resources. But probably I’m just thinking about this in the wrong way?

---

<div class="post-metadata">

**Author:** ![brucellino1](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/brucellino1/32/16147_2.png) [@brucellino1](https://discuss.hashicorp.com/u/brucellino1)\
**Post date:** [November 21, 2024, 4:21pm UTC](https://discuss.hashicorp.com/t/limit-job-dispatch-calls-for-parameterized-batch-job/57258/4 "2024-11-21T16:21:20Z")

</div>

Chiming in here after more than a year, since I’ve hit the same behaviour. In my case, I have constraints on a job, which gets around the issue of overloading the agent running it. Other dispatches end up in “failed” while there are not enough resources, but the scheduler still knows about them and keeps them in the queue.

As jobs complete, resources are freed and the previously failed allocations are placed.

Does this solve your issue?

---

<div class="post-metadata">

**Author:** ![nickfreedy574](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/nickfreedy574/32/42996_2.png) [@nickfreedy574](https://discuss.hashicorp.com/u/nickfreedy574)\
**Post date:** [December 1, 2024, 12:36pm UTC](https://discuss.hashicorp.com/t/limit-job-dispatch-calls-for-parameterized-batch-job/57258/5 "2024-12-01T12:36:21Z")

</div>

> [@chrismo](#):
>
> I accidentally flooded a staging server with a bunch of redundant job dispatch calls. It quickly consumed the available resources on the single client node I had setup and the whole thing fell over. I was able to stop all of the allocations and get it cleaned up, but - what constraints can I put into the job definition to prevent this problem in the future?

To prevent redundant job dispatch calls and resource exhaustion on a staging server, you can implement the following constraints in the job definition:

Rate Limiting: Add a rate\_limit constraint to throttle job dispatch frequency.

Concurrency Limit: Use a max\_concurrency setting to restrict the number of jobs running simultaneously.

Retry Behavior: Define retry limits with backoff strategies to prevent rapid re-dispatch of failed jobs.

Queue Length: Set a queue\_size limit to cap the number of pending jobs in the queue.

Timeouts: Implement timeouts for individual jobs to avoid resource locking.

Health Checks: Add monitoring and alerting for unusual resource usage patterns.
