Runtimes
Vercel supports multiple runtimes for your functions. Each runtime has its own set of libraries, APIs, and functionality that provides different trade-offs and benefits.
Runtimes transform your source code intoFunctions, which are served by ourEdge Network.
Vercel Functions support the following official runtimes:
Runtime | Description |
---|---|
Node.js | The Node.js runtime takes an entrypoint of a Node.js function, builds its dependencies (if any) and bundles them into a Vercel Function. |
Go RuntimeGo | The Go runtime takes in a Go program that defines a singular HTTP handler and outputs it as a Vercel Function. |
Python | The Python runtime takes in a Python program that defines a singular HTTP handler and outputs it as a Vercel Function. |
Ruby | The Ruby runtime takes in a Ruby program that defines a singular HTTP handler and outputs it as a Vercel Function. |
Edge | The Edge runtime is built on top of the V8 engine, allowing it to run in isolated execution environments that don't require a container or virtual machine. |
If you would like to use a language that Vercel does not support by default, you can use a community runtime by setting thefunctions
property invercel.json
. For more information on configuring other runtimes, seeConfiguring your function runtime.
The following community runtimes are recommended by Vercel:
Runtime | Runtime Module | Docs |
---|---|---|
Bash | vercel-bash | https://github.com/importpw/vercel-bash |
Deno | vercel-deno | https://github.com/vercel-community/deno |
PHP | vercel-php | https://github.com/vercel-community/php |
Rust | vercel-rust | https://github.com/vercel-community/rust |
You can create a community runtime by using theRuntime API. Alternatively, you can use theBuild Output API.
- Location: Deployed as region-first,can customize location. Pro and Enterprise teams can setmultiple regions
- Failover: Automatic failover todefined regions
- Automatic concurrency scaling: Auto-scales up to 30,000 (Hobby and Pro) or 100,000+ (Enterprise) concurrency
- Isolation boundary: microVM
- File system support: Read-only filesystem with writable
/tmp
scratch space up to 500 MB - Archiving: Functions are archived when not invoked
- Functions created per deployment: Hobby: Framework-dependent, Pro and Enterprise: No limit
Location refers to where your functions areexecuted. Vercel Functions are region-first, and can bedeployed to up to3 regions on Pro or18 on Enterprise. Deploying to more regions than your plan allows for will cause your deployment to fail before entering thebuild step.
Vercel's failover mode refers to the system's behavior when a function fails to execute because of data center downtime.
Vercel providesredundancy and automatic failover for Vercel Functions using the Edge runtime. For Vercel Functions on the Node.js runtime, you can use thefunctionFailoverRegions
configuration in yourvercel.json
file to specify which regions the function should automatically failover to.
In Vercel, the isolation boundary refers to the separation of individual instances of a function to ensure they don't interfere with each other. This provides a secure execution environment for each function.
With traditional serverless infrastructure, each function uses a microVM for isolation, which provides strong security but also makes them slower to start and more resource intensive.
Filesystem support refers to a function's ability to read and write to the filesystem. Vercel functions have a read-only filesystem with writable/tmp
scratch space up to 500 MB.
Vercel Functions are archived when they are not invoked:
- Within 2 weeks forProduction Deployments
- Within 48 hours forPreview Deployments
Archived functions will be unarchived when they're invoked, which can make the initialcold start time at least 1 second longer than usual.
When usingNext.js orSvelteKit on Vercel, dynamic code (APIs, server-rendered pages, or dynamicfetch
requests) will be bundled into the fewest number of Vercel Functions possible, to help reduce cold starts. Because of this, it's unlikely that you'll hit the limit of 12 bundled Vercel Functions per deployment.
When using otherframeworks, or Vercel Functionsdirectly without a framework, every API maps directly to one Vercel Function. For example, having five files insideapi/
would create five Vercel Functions. For Hobby, this approach is limited to 12 Vercel Functions per deployment.
A runtime can retain an archive of up to100 MB of the filesystem at build time. The cache key is generated as a combination of:
- Project name
- Team ID or User ID
- Entrypoint path (e.g.,
api/users/index.go
) - Runtime identifier including version (e.g.:
@vercel/go@0.0.1
)
The cache will be invalidated if any of those items changes. You can bypass the cache by runningvercel -f
.
You can useenvironment variables to manage dynamic values and sensitive information affecting the operation of your functions. Vercel allows developers to define these variables either at deployment or during runtime.
You can use a total of64 KB in environments variables per-deployment on Vercel. This limit is for all variables combined, and so no single variable can be larger than64 KB.
The following features are supported by Vercel Functions:
Node.js runtime (and more) | |
---|---|
Secure Compute | Supported |
Streaming | Supported, depending on the framework |
Cron jobs | Supported |
Vercel Storage | Supported |
Edge Config | Supported only in Node.js runtime |
OTEL | Supported |
Vercel'sSecure Compute feature offers enhanced security for your Vercel Functions, including dedicated IP addresses and VPN options. This can be particularly important for functions that handle sensitive data.
Streaming refers to the ability to send or receive data in a continuous flow.
The Node.js runtime supports streaming by default. Streaming is also supported when using thePython runtime.
Vercel Functions have amaximum duration, meaning that it isn't possible to stream indefinitely.
Node.js and Edge runtime streaming functions support thewaitUntil
method, which allows for an asynchronous task to be performed during the lifecycle of the request. This means that while your function will likely run for the same amount of time, your end-users can have a better, more interactive experience.
Cron jobs are time-based scheduling tools used to automate repetitive tasks. When a cron job is triggered through thecron expression, it calls a Vercel Function.
From your function, you can communicate with a choice ofdata stores. To ensure low-latency responses, it's crucial to have compute close to your databases. Always deploy your databases in regions closest to your functions to avoid long network roundtrips. For more information, see ourbest practices documentation.
AnEdge Config is a global data store that enables experimentation with feature flags, A/B testing, critical redirects, and IP blocking. It enables you to read data at the edge without querying an external database or hitting upstream servers.
Vercel has anOpenTelemetry (OTEL) collector that allows you to send OTEL traces from your Vercel Functions to application performance monitoring (APM) vendors such as New Relic.
Was this helpful?