Azure-functions-host: Node.js function takes 2-4 minutes to start after any code change

Created on 17 Aug 2018  路  5Comments  路  Source: Azure/azure-functions-host

I am using Azure Functions v2.0-beta and writing timer-triggered functions in Node.js.

When I make any change to my JavaScript file, the first run of a function takes approximately 2-4 minutes instead of the usual milliseconds.

During that time, the functions consumes a large number of execution units and also the storage usage spikes a lot, with tens of thousands of read or write requests.

Here's an example of a relatively fast startup which took 2 minutes:

2018-08-17T19:22:03.001 [Information] Executing 'Functions./my function name/' (Reason='Timer fired at 2018-08-17T19:22:03.0013209+00:00', Id=3ff72e1c-8dd9-4fd9-925c-8057aac25229)

2018-08-17T19:24:06.510 [Information] Executed 'Functions./my function name/' (Succeeded, Id=3ff72e1c-8dd9-4fd9-925c-8057aac25229)

The function is running in the East Asia region.

Repro steps

  1. Create a timer-triggered JavaScript function.
  2. Install packages such as request and request-promise-native.
  3. Try to run the function.
  4. Modify the JavaScript file (e.g. add a space).
  5. The first startup is slow.

Expected behavior

Expect the function to start up within a few seconds and do not consume thousands of write operations on the storage.

Most helpful comment

For functions with lots of dependencies, our recommendation is to use Run From Package with Zip Deployment (docs here: https://docs.microsoft.com/en-us/azure/azure-functions/deployment-zip-push#run-functions-from-the-deployment-package)

All 5 comments

As an example:

  • I deployed the code of my function (one or two JavaScript files) several times over half an hour;
  • Each time it took 3-5 minutes for the function to start working again (I did not restart the service);
  • I got charged for approximately 300,000 File operations in this function's storage account.

Hi @catcher-in-the-try, sorry about the delayed response on this. We have made a lot of changes leading to our recent GA - is this still an issue?

For functions with lots of dependencies, our recommendation is to use Run From Package with Zip Deployment (docs here: https://docs.microsoft.com/en-us/azure/azure-functions/deployment-zip-push#run-functions-from-the-deployment-package)

I found my way here after noticing my rather basic Node.js Azure Functions app was taking a few minutes to respond to the infrequent requests it receives and its storage account was reporting a large amount of write operations correlated with the requests. It looks like "Run From Package with Zip Deployment" is going to be very helpful. 馃榿

馃憤 ! We're working to make this the default deployment method everywhere too!

Was this page helpful?
0 / 5 - 0 ratings