# Performance consideration for calling invokeAsynchronous multiple times

**URL:** <https://forum.inductiveautomation.com/t/performance-consideration-for-calling-invokeasynchronous-multiple-times/63037>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [August 16, 2022, 11:30am UTC](https://forum.inductiveautomation.com/t/performance-consideration-for-calling-invokeasynchronous-multiple-times/63037 "2022-08-16T11:30:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shrikant](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@shrikant](https://forum.inductiveautomation.com/u/shrikant)\
**Post date:** [August 16, 2022, 11:30am UTC](https://forum.inductiveautomation.com/t/performance-consideration-for-calling-invokeasynchronous-multiple-times/63037/1 "2022-08-16T11:30:37Z")

</div>

I have a gateway timer that runs every 15 minutes. This function browses tags and calls `system.util.invokeAsynchronous` for each tag that matches certain criteria. There can be 100 - 150 such tags, so that many instances can run in parallel at every execution of timer. Function in `invokeAsynchronous` call queries tag history using `queryTagHistory` function and writes to a specific tag.

Is there any impact on gateway performance calling `invokeAsynchronous` in above manner? Is there any way to minimise the load?

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [August 16, 2022, 11:32am UTC](https://forum.inductiveautomation.com/t/performance-consideration-for-calling-invokeasynchronous-multiple-times/63037/2 "2022-08-16T11:32:48Z")

</div>

Another thought… could you browse and then make a list of tags to pass into system.tag.queryTagHistory rather than one at a time? Then parse them back out when you get the data back?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 16, 2022, 11:39am UTC](https://forum.inductiveautomation.com/t/performance-consideration-for-calling-invokeasynchronous-multiple-times/63037/3 "2022-08-16T11:39:34Z")

</div>

I would have two scripts. One to gather the approbriate tags and store the names-- perhaps to a dataset or document tag. The second one to gather the names from the tag and run the history query.

---

<div class="post-metadata">

**Author:** ![shrikant](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@shrikant](https://forum.inductiveautomation.com/u/shrikant)\
**Post date:** [August 16, 2022, 11:50am UTC](https://forum.inductiveautomation.com/t/performance-consideration-for-calling-invokeasynchronous-multiple-times/63037/4 "2022-08-16T11:50:21Z")

</div>

@bschroeder @JordanCClark Thank you for you quick replies. I agree that methods suggested by you won’t take long to execute. Using `invokeAsynchronous`, I was thinking to update all tags in at almost same time.  
But in general, is there any limit on number of `invokeAsynchronous` simultaneous calls can be made?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 16, 2022, 12:01pm UTC](https://forum.inductiveautomation.com/t/performance-consideration-for-calling-invokeasynchronous-multiple-times/63037/5 "2022-08-16T12:01:44Z")

</div>

> [@shrikant](#):
>
> Is there any impact on gateway performance calling `invokeAsynchronous` in above manner? Is there any way to minimise the load?

Yes there is an impact. The processor is only capable of handling so many things at once (e.g. there is a limit to how many threads can run simultaneously). Once that happens, the threads are queued in a schedule and eventually other things can/will start to suffer.

You can minimize the load by pooling the load, as @bschroeder and @JordanCClark pointed out.

IMO, there is no need for `invokeAsynchronous` here. Timer Events can be configured to run on their own dedicated thread.

---

<div class="post-metadata">

**Author:** ![shrikant](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@shrikant](https://forum.inductiveautomation.com/u/shrikant)\
**Post date:** [August 16, 2022, 12:21pm UTC](https://forum.inductiveautomation.com/t/performance-consideration-for-calling-invokeasynchronous-multiple-times/63037/6 "2022-08-16T12:21:25Z")

</div>

Thanks @lrose for the clarification. I will try out alternative approaches suggested by @bschroeder and @JordanCClark.

Thanks again everybody!
