Configuring Memory and CPU for Vercel Functions
Learn how to set the memory / CPU of a Vercel Function.The memory configuration of a function determines how much memory and CPU the function can use while executing. This guide will walk you through configuring the memory for your Vercel Functions.
By default, Serverless Functions execute with 1024
MB of memory unless you have custom overrides in the vercel.json
config file per function level.
To change the default function memory size in the dashboard:
- Choose the appropriate project from your dashboard on Vercel
- Navigate to the Settings tab
- From the left side, select Functions
- In the Function CPU section, select your preferred memory size option:
The change will be applied to your future deployments. Therefore, a new Deployment is required for your changes to take effect.
Any custom memory
size
set in the vercel.json
file will take precedence over the default memory
size set in the dashboard.
The memory size you select will also determine the CPU allocated to your Serverless Functions. The following table shows the memory and CPU allocation for each type:
Type | Memory / CPU | Use |
---|---|---|
Basic | 1024 MB / 0.6 vCPU | Cost-effective option for lightweight apps and APIs |
Standard | 1769 MB / 1 vCPU | Predictable performance for production workloads |
Performance | 3009 MB / 1.7 vCPUs | Increased performance for latency-sensitive applications and SSR workloads |
See Pricing for more information on the cost of each type.
Project created before 2019-11-08T00:00:00.000Z have the default function memory size set to 1024 MB/0.6 vCPU for Hobby plan, and 3008 MB/1.67 vCPU for Pro and Enterprise plan. Although the dashboard may not have any memory size option selected by default for those projects, you can start using the new memory size options by selecting your preferred memory size in the dashboard.
You can configure custom memory size up to the allowed limits for your plan by following these steps:
- Use the
functions
property within yourvercel.json
config file - Use a glob pattern to specify the path
- Specify an integer defining the
memory
size in MB for your Serverless Function (between 128 and 3009)
The order in which you specify file patterns is important. For more information, see Glob pattern.
{
"functions": {
"api/test.js": {
"memory": 3009
},
"api/*.js": {
"memory": 3009,
"maxDuration": 30
}
}
}
To check the memory size of your functions in the dashboard, follow these steps:
- Go to the deployment page you want to review
- Click on the Functions tab
- Select the function from the dropdown menu, and the memory size of the function will be displayed in the Memory Size section
To learn more about the maximum size of your function's memory, see Max memory size.
Was this helpful?