Now available in Beta: Background Functions

Big news! We’re excited to announce that Background Functions are available in Beta for all teams with a Pro plan or higher.

In the time since we first released Netlify Functions, many customers have requested the ability to make their functions run longer than the default 10-second time limit. After all, if Netlify Functions use AWS Lambda under the hood, why can’t we have Lambda’s 15-minute time limit?

The trouble is, we pass Lambdas through an API gateway proxy layer. This makes it so you can call a function from a relative path on your site, like /.netlify/functions/hello and receive a response back to the client. If you used AWS’s API Gateway, you’d have a seconds-long timeout, too. That’s because you can’t have a connection (or your app user on the other end) waiting for minutes to get a response.

So how do you run long-running serverless functions? You run them asynchronously, in the background. Send a call to a background function, and it will return a confirmation that the request was received, then continue doing its work. The client isn’t left waiting, and the function can take the time it needs to finish its task — up to the full 15 minutes.

Want to try them out? To find out more about common use cases and how to create background functions check out our blog and docs.


Returns occurs when request is successfully sent, however, is there a way to see if the execution was successful or pull a response later on?
IE: Sign a user up to email list, is there a way to confirm success (initial function return an id to query for progress of the function or check if there was an error during execution?)

Hey Aaron!

I think the answer is that you’ll want to record success or failure on a separate system (if you can’t infer success from what the function does, such as adding a subscriber to your mailing list or an entry to a spreadsheet), for monitoring. This is probably table stakes if you need to be notified of failures in any function, anyway, since our function logs are short-lived and non-exportable at present. Jessica might have some different ideas but that would be the advice I’d give :slight_smile:

If I have a function eg. upload-file.js I call it as /.netlify/functions/upload-file

If I rename it to upload-file-background.js do I have to change all the calls to /.netlify/functions/upload-file-background or is the background appendix ignored?

hi michal, sorry for the slow reply. You will have to change the calls, the appendix is not ignored.

@michal, yes, the new endpoint will include the -background suffix. Part of the reason we made this choice is because of customer use cases we encountered where it was useful to have two related functions with different execution styles, calling for both a /.netlify/functions/do-something endpoint as well as a /.netlify/functions/do-something-background one.

However, if you’re completely replacing your former upload-file function with a new background version in all cases, you could add a redirect rule so that all of your old calls will be redirected to the new endpoint. In a _redirects file, the format would be:

/.netlify/functions/upload-file  /.netlify/functions/upload-file-background

You can find out more about redirect rules in the docs: