azure-functions-python-worker
azure-functions-python-worker copied to clipboard
Move invocation logging into a thread pool executor
This change moves the logging call inside the function invocation callback into a thread pool executor (With a max size of 1). Effectively allows the logging call to happen concurrently with the function invocation.
In real-terms, with a patched function host, the response times were:
| 50 | 66 | 75 | 80 | 90 | 95 | 98 | 99 | |
|---|---|---|---|---|---|---|---|---|
| Original | 15 | 17 | 18 | 20 | 27 | 42 | 58 | 64 |
| Patched | 14 | 16 | 17 | 19 | 26 | 35 | 47 | 57 |
At the 95th percentile an improvement of 7ms per request (18%).
IF the customer is using logging inside their function, we should consider making the thread pool executor available/patched on the logger instance.
This should be extended to cover the customer logging function code as well. The Python HTTP function demo spends 70% of its time on line 7

With the threaded logger.