# Script execution time

**URL:** <https://forum.inductiveautomation.com/t/script-execution-time/98211>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [November 5, 2024, 2:46pm UTC](https://forum.inductiveautomation.com/t/script-execution-time/98211 "2024-11-05T14:46:42Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 5, 2024, 3:18pm UTC](https://forum.inductiveautomation.com/t/script-execution-time/98211/2 "2024-11-05T15:18:27Z")

</div>

Each kind of gateway event uses its own thread model, and run independently (parallel) of other event types. Java and Jython are fully multi-threaded, unlike CPython.

Some event types offer a single shared thread or a dedicated thread per event definition, selectable.

Most event types, like gateway tag change events, simply use a dedicated thread per event definition. (Multiple tags assigned to such an event are processed one at a time, in order.) If you want two threads handling various tag events, split the lists of tags across multiple definitions. These event types never drop events, though you might crash your gateway on memory usage if your scripts don't keep up, on average.

Tag events, defined directly on the tag (outside the project), use a thread pool, size three, to run tag events in parallel. If more than three scripts are running from this source, more events will queue up. Unlike the queue for project-based tag change events, tag events have per-tag queues limited to five entries. Any events that occur with a full queue will set the missed event flag and be discarded.

Expression tags have their own thread pool, also size three, that will be used for any expressions involving `runScript()`.

Tag events (on the tag) and `runScript()` calls should always be designed to run in single digit milliseconds, or you risk blocking **all** other tags' scripts/expressions. Some rules of thumb for tag event scripts:

> [@Ignition 8.1 Slow Executing Scripts](https://forum.inductiveautomation.com/t/ignition-8-1-slow-executing-scripts/97971/5):
>
> Tag events run in a limited thread pool (three threads, by default). You must not do anything in a tag event script that takes more than a handful of milliseconds. (Like, single digit milliseconds.) This means your tag events must not: Make any database calls, except Insert/Update via the Store and Forward system. Make any direct OPC reads, or any OPC tag writes, or direct OPC writes, as these block for many seconds if there are communication problems. Use any system or java function…

---

_[View the full topic](https://forum.inductiveautomation.com/t/script-execution-time/98211)._
