Configuring Memory and CPU for Vercel Functions

Learn how to set the memory / CPU of a Vercel Function.
Table of Contents
This can only be set for Serverless Functions

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:

  1. Choose the appropriate project from your dashboard on Vercel
  2. Navigate to the Settings tab
  3. From the left side, select Functions
  4. In the Function CPU section, select your preferred memory size option:
    The Function CPU setting in a Vercel project's dashboard
    The Function CPU setting in a Vercel project's dashboard

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:

TypeMemory / CPUUse
Basic1024 MB / 0.6 vCPUCost-effective option for lightweight apps and APIs
Standard1769 MB / 1 vCPUPredictable performance for production workloads
Performance3009 MB / 1.7 vCPUsIncreased 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:

  1. Use the functions property within your vercel.json config file
  2. Use a glob pattern to specify the path
  3. 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.

vercel.json
{
  "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:

  1. Go to the deployment page you want to review
  2. Click on the Functions tab
  3. 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.

Last updated on April 27, 2024