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

Node.js function takes 2-4 minutes to start after any code change #3281

Closed
anton-bot opened this issue Aug 17, 2018 · 5 comments
Closed

Node.js function takes 2-4 minutes to start after any code change #3281

anton-bot opened this issue Aug 17, 2018 · 5 comments
Assignees

Comments

@anton-bot
Copy link

anton-bot commented Aug 17, 2018

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.

@anton-bot
Copy link
Author

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.

@mhoeger
Copy link
Contributor

mhoeger commented Oct 12, 2018

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?

@mhoeger mhoeger self-assigned this Oct 12, 2018
@mhoeger mhoeger added this to the Active Questions milestone Oct 12, 2018
@mhoeger
Copy link
Contributor

mhoeger commented Mar 20, 2019

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)

@mhoeger mhoeger closed this as completed Mar 20, 2019
@FlsZen
Copy link

FlsZen commented Mar 30, 2019

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. 😁

@mhoeger
Copy link
Contributor

mhoeger commented Mar 30, 2019

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

@ghost ghost locked as resolved and limited conversation to collaborators Jan 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants