When extending your project with Serverless Functions, you might find yourself in a situation where adjusting the default behavior is necessary.
Today, we are adding a new
functions
configuration property to allow you to do just this.Note: To take advantage of this feature, you need to use our Git Integration or Vercel CLI.
Custom memory & execution duration
In most cases, zero configuration is required to create deployments with Vercel. Every Serverless Function (in all projects created after November 8th) receives the following attributes by default:
- Memory: 1024 MB (1 GB)
- Maximum Execution Duration: 10s (Hobby), 300s (Pro), or 900s (Enterprise)
Now, you can customize these values in your
vercel.json
file like so:{ "functions": { "api/test.js": { "memory": 3008, "maxDuration": 10 } } }
An example `vercel.json` file that shows how to customize the `functions` property.
Read more about the constraints for each property in our documentation.
Community runtimes
When deploying Serverless Functions without configuration (using the /api directory), you can choose from a list of officially supported languages.
If the language you'd like to use is not part of this list, you can add
functions
to your vercel.json
file to assign Community Runtimes to your Serverless Functions.Community Runtimes are provided by a third-party, for example, vercel-php:
{ "functions": { "api/test.php": { "runtime": "vercel-php@0.0.10" } } }
An example `vercel.json` file that shows how to configure the `vercel-php` Community Runtime.
After configuring the
functions
property, your api/test.php
Serverless Function will be executed using the vercel-php
Community Runtime. If you are interested in using a Community Runtime or creating one yourself, check out the following documentation pages:
API changes
If you are developing applications on top of the Vercel API, you will need to use
v11
of the deployment creation endpoint to take advantage of the functions
property.Conclusion
With the new
functions
property, you can configure the memory and maximum execution duration of your Serverless Functions, or assign a custom runtime.Note: The
builds
property will be deprecated in favor of functions
.This is just one of several features we are planning to launch in order to support advanced use cases of Serverless Functions on Vercel.
Let us know what you think about this change!