I’ve restarted work on a project that shelved a while ago due to low priority. Part of my update work has been reducing the load of the session on our gateway. I’m managed to reduce the amount of DB polls from ~400/s per session to ~6/s per session.
The problem I am running into is each session can spawn between 100 and 350 TIMED_WAITING threads. I have tested this and it appears to be tied to the number of instances displayed in a flex repeater on the main page of the project. A large number of the timed_waiting threads are named Perspective_Worker
Part of my work in reducing the number of DB polls by the session was to pull as much data calculation /fetching out of the templates used in the repeater and having it calculated/determined in a session global script and then passed via parameters to each template instance.
Each template contains an embedded view that uses a type parameter to build a path to the required embedded view. This was to replace the original template which had one of each data type (Checkbox, text, number, date, etc) and showed only the one used. These data entry fields have an ‘onActionPerformed’ script that will write the new data value to the database if it changed. Each template also has some labels that either hide or show based on another value that is calculated outside the repeater then passed in. There are still several expressions executing on each template.
I am aware that some of the answers to the questions below will vary with the application. Some more info about the project I am working on:
The project is meant to be a digital buildbook. There are different section numbers the user can select, and a flex repeater displays the steps of the selected section. Current state of the step is displayed, any data entered for that step, and a timestamp with the UID of the user who entered the data/signed off on the step.
There is also a section on a step that will appear if the step requires third party validation. This hidden section is included in the step template and show as needed. This section has a checkbox, label, and a timestamp with the UID and time of signoff. Additionally, if there is something that deviates from norm, there is a label that will show at the top of the step indicating there is additional info available.
I am trying to reduce the amount of timed waiting threads as much as possible. As such I had the following questions:
- Does having an expression or a transform script spawn a timed thread per expression?
- What things/operations spawn timed threads?
- Is there a lower limit that exists for amount of threads per perspective session that increases with project complexity?
- What is an ideal number of threads per perspective session?
- Is this a case where it would be better to start from the ground up instead of reworking an old project?
I’ve also attached a thread dump in case it may be of use.Ignition Gateway_thread_dump20210222-212235.txt (427.8 KB)