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

Static Web Application - Cold Start of APIs sk_render #185

Open
kane81 opened this issue Nov 18, 2024 · 2 comments
Open

Static Web Application - Cold Start of APIs sk_render #185

kane81 opened this issue Nov 18, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@kane81
Copy link

kane81 commented Nov 18, 2024

Hello,

The cold start of the Static Web App API function app sk_render is really causing us a problem and managed function apps cannot be configured to be warm.

Our current workaround is to ping the site regularly to keep it warm, however we would prefer a less hacky approach.

Is it possible to somehow run sk_render in a dedicated function app and then configure the adapter to use the dedicated function app which we can then configure to be warm?

Or do you or others have any other suggestions how to manage this issue?

Thank you

@Crelde
Copy link

Crelde commented Nov 26, 2024

Same issue here, looking for a good fix. Speaking to Azure support they recommend not using (managed) azure functions in the SWA as there is no way to avoid cold starts.
They mentioned that if the function app is idle for 5 ish minutes that the worker will be deallocated due to the way consumption plan's handle worker allocation. They recommended to either include a timertrigger that runs every minute to keep the app warmed up. (I don't know how to add additional Azure Functions to the deployed package). Or to move the Function App into an App Service Plan to have always-ready instances.

@geoffrich
Copy link
Owner

This seems to be an issue with other frameworks on SWA, not just Svelte - see Azure/static-web-apps#1545

I don't have the bandwidth right now to figure out how to support non-managed function apps with this adapter, but contributions are welcome! You should be able to clone the adapter into your project's repo and import from it directly instead of from node_modules. Then you can test any modifications you make with your deployed app.

There isn't a lot of magic with this adapter, it just bundles an azure function for server-side rendering and then writes it to the build/server folder (or a custom directory). Then, the SWA config is set to re-write all GET calls without a prerendered asset to that route. You should be able to edit the built function directly, e.g. if different configuration needs to be set to make it non-managed.

@geoffrich geoffrich added the help wanted Extra attention is needed label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants