-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idle thread timeout rules for thread pools #107017
Comments
Tagging subscribers to this area: @mangod9 |
The timeout can be changed with the ThreadTimeoutMs setting with an environment variable or with an AppContext config var. There's also a setting to keep a minimum number of threads alive (ThreadsToKeepAlive). |
I'm glad to receive your reply I tried to change the timeout according to the above configuration, but it didn't work. In the local test, the thread pool started to recycle after 80 seconds. The example code is as follows
|
I just tried it and it seems to be working as expected on .NET 8, when either config var is set to -1, the thread pool threads stay and don't time out. In .NET 6, the config vars are available from runtime version 6.0.25. Although setting the config vars as in the example should work for this example, they are read only one time when the thread pool is first used, which could be very early in some cases. It would be better to set the environment variables in the shell before starting the process, or to set the AppContext settings in the *.runtimeconfig.json. Also if both the environment variable and AppContext settings are set, the environment variable setting is used. |
Thank you very much. By setting the environment variables in the shell and then starting the program, the thread pool no longer recycles threads. |
I want to change the timeout of the idle thread in the thread pool. How should I control this?
I hope to increase MinThreads and increase the timeout of the idle thread to deal with the impact of the thread pool creating threads on the CPU when the burst traffic increases. But I can't find how to change the timeout rule for this idle thread
The text was updated successfully, but these errors were encountered: