azure-functions-python-worker icon indicating copy to clipboard operation
azure-functions-python-worker copied to clipboard

Move invocation logging into a thread pool executor

Open tonybaloney opened this issue 3 years ago • 2 comments

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
screenshot 2022-06-01 at 11 37 55

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.

tonybaloney avatar Jun 01 '22 01:06 tonybaloney

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

image

tonybaloney avatar Jun 02 '22 06:06 tonybaloney

image With the threaded logger.

tonybaloney avatar Jun 03 '22 03:06 tonybaloney