Skip to content
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

Fix PYTHON_THREADPOOL_THREAD_COUNT not apply to Linux Conusmption #774

Merged
merged 9 commits into from
Nov 6, 2020

Conversation

Hazhzeng
Copy link
Contributor

@Hazhzeng Hazhzeng commented Nov 3, 2020

Description

This is a fix to an issue where in Linux Consumption, the PYTHON_THREADPOOL_THREAD_COUNT app setting is not properly applied to an instance during specialization. This will make the Python worker in Linux Consumption ignore the app setting, making the maximum worker count always to 1.

Miscellaneous:

  1. I move @patch decorator in unittests to use with patch() syntax, since previously, it suppresses all assertion exceptions in async test cases.
  2. Add a reload_environment() function in testutil to help us mock Linux Consumption specialization

PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made and CI is passing.

Quality of Code and Contribution Guidelines

@Hazhzeng
Copy link
Contributor Author

Hazhzeng commented Nov 3, 2020

Known CI issue in Python Worker CI, Python 3.9 windows will fail here.

Copy link
Member

@vrdmr vrdmr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
some nits

azure_functions_worker/dispatcher.py Outdated Show resolved Hide resolved
azure_functions_worker/dispatcher.py Outdated Show resolved Hide resolved
@Hazhzeng Hazhzeng merged commit 130ac0c into dev Nov 6, 2020
@Hazhzeng Hazhzeng deleted the hazeng/fix-thread-log branch November 6, 2020 20:16
@casper-79
Copy link

Hi @vrdmr

Any idea when this fix is going into production? We have been working on understanding this behaviour for weeks and I just stumbled over this pull request by accident ...

Cheers,

Casper

@anirudhgarg
Copy link
Member

Its already in Linux Premium. It is rolling out in Linux Consumption as we speak. Should be everywhere by the middle of next week.

@casper-79
Copy link

Hi @anirudhgarg

I just tried consumption plan in west europe and I am still unable to go beyond a single thread. Do you have any documentation on how this feature is supposed to work, ideally with working code examples?

Cheers,

Casper

@casper-79
Copy link

Hi @vrdmr and @anirudhgarg

Any update on this? Documentation or working code examples ...

Cheers,

Casper

@vrdmr
Copy link
Member

vrdmr commented Dec 8, 2020

Hi @casper-79, @stefanushinardi is working on the documentation update (PR: https://github.com/MicrosoftDocs/azure-docs-pr/pull/139057) and this should go in soon. Once that PR is in, the new perf-guidance page for Python function apps should light-up immediately.

Please let us know if you are looking for something specific. Thanks.

@casper-79
Copy link

Thanks @vrdmr

Unfortunately, there seems to be an error with the PR link you provided (404). Is the performance guidance page you are referring to something that will show up in the Azure portal?

Cheers,

Casper

@anirudhgarg
Copy link
Member

@casper-79 I think you might be asking for specific instructions on how to use this. (You might not have access to the Azure Docs PR)

Basically you just add an app setting: PYTHON_THREADPOOL_THREAD_COUNT and set it to the number of threads that you want.

@jokoso
Copy link

jokoso commented Jan 4, 2021

Hi @casper-79, @stefanushinardi is working on the documentation update (PR: MicrosoftDocs/azure-docs-pr#139057) and this should go in soon. Once that PR is in, the new perf-guidance page for Python function apps should light-up immediately.

Please let us know if you are looking for something specific. Thanks.

@anirudhgarg Any idea when the documentation will be finished? The link currently leads to a 404.

@vrdmr
Copy link
Member

vrdmr commented Jan 5, 2021

@jokoso - The docs PR was merged today and the scaling-and-performance section should update soon.

PYTHON_THREADPOOL_THREAD_COUNT

Specifies the maximum number of threads that a Python language worker would use to execute function invocations, with a default value of 1 for Python version 3.8 and below. For Python version 3.9 and above, the value is set to None. Note that this setting does not guarantee the number of threads that would be set during executions. The setting allows Python to expand the number of threads to the specified value. The setting only applies to Python functions apps. Additionally, the setting applies to synchronous functions invocation and not for coroutines.

Key Sample value Max value
PYTHON_THREADPOOL_THREAD_COUNT 2 32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants