Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Lisa_Sun
Support
Support

Is there anyway to adjust the ThreadPool in Qlik Sense?

Qlik Sense

All version from 3.1 to November 2017 release.


When attempting to restart the cluster through the windows services the printing and/or the scheduler will be unable to close in the expected timeframe.  The error 'Unexpected exception occured when posting alive to Master There were not enough free threads in the ThreadPool to complete the operation.' can be found from the scheduler log.

Current Workaround:

Force kill the task associated to the PID for the service which will ensure it stops. Upon start of the service it will now function as expected.


Is there anyway to adjust the threadpool? 


For my understanding,  ThreadPool is used to maintain multiple threads to process the incoming requests.  Each thread will be associate with the windows process.  The ThreadPool is created for the performance improvement.  But how many threads it should be created, it is also based on how many current tasks and what type of the tasks.  For the task which load heavy data or do complex calculation, the assigned thread will consume resource heavily.  That will impact other tasks performance as well.    If more tasks are requesting to be run but the threads are busy on the big task, then more thread will be required.  I guess this is what happened. 

In general, we need to monitor the number of threads in the threadpool and the number of concurrent tasks.  Then check the CPU and memory usage.  Accordingly decide how many threads are required.  But I could not find any information on this part.   It can be coded but not sure if this is configurable.  Could anyone please help to confirm?

Meanwhile for multiple scheduler nodes environment,  it is important to allocate the task to different scheduler nodes to achieve the best performance and avoid the resource shortage.  The frequency of task reload needs to be adjusted if it helps.

Is there any suggestion?

Thank you

Best Regards

Lisa

Help users find answers! Don't forget to mark a solution that worked for you! If already marked, give it a thumbs up!
2 Replies
Lisa_Sun
Support
Support
Author

Here is the information found from internet.  It explains how threadpool works.  But how it works in Qlik, I am confirming internally.

https://msdn.microsoft.com/en-us/library/ms973903.aspx

https://docs.microsoft.com/en-us/dotnet/standard/threading/the-managed-thread-pool

Maximum Number of Thread Pool Threads

The number of operations that can be queued to the thread pool is limited only by available memory; however, the thread pool limits the number of threads that can be active in the process simultaneously. Beginning with the .NET Framework 4, the default size of the thread pool for a process depends on several factors, such as the size of the virtual address space. A process can call the GetMaxThreads method to determine the number of threads.

You can control the maximum number of threads by using the GetMaxThreads and SetMaxThreads methods.

Help users find answers! Don't forget to mark a solution that worked for you! If already marked, give it a thumbs up!
martinsandin
Employee
Employee

Hello Lisa,

That sounds like a bug, I've never seen that happen. Increasing the number of threads would only be a temporary fix and in reality there is no reason the Slave Scheduler should run out of threads just because the it can't contact the Master soon enough and furthermore no reason the slave shouldn't be able to shut down for the same reason. Please file an issue and include the logs and any relevant circumstances (time, system topology, ...).