I have a piece of code that was creating a new temporal worker on every execution. (~every 5 minutes).
I soon realized that it was a bad practise to do that but I found out that creating a new worker (with same Id and queue) is causing my application to consume memory like there’s no tomorrow.
The consumption of memory in a 10 minute period went from ~50MB to 20KB once I changed the code to create only one worker.
I am curious to find out
- Why does creating a new worker cause memory to be held like that?
- Why is the worker not being shutdown if it wasn’t used for five minutes?
- Which pattern out of these two is recommended?
- One worker per workflow
- One worker per application