Serverless Functions enable you to run code on-demand and at scale without setting up your own compute infrastructure. When people visit one of your API routes that uses a Serverless Function, the Function is invoked in a region on Vercel's Edge Network. If your Function depends on a database, and is invoked in a region far from that database, the response time will be slow.
In order to run your Serverless Functions as fast as possible, Vercel can deploy your code to dozens of locations (called regions) across the world.
Selecting a region for your Functions allows you to choose where your Serverless Functions are deployed. Deploying your Serverless Functions to a region close to your data sources (such as your database) can greatly improve performance. Reading data from your data sources will have less latency when your Serverless Functions and data sources are physically close.
You can set a default Serverless Function region in your project's Dashboard settings on Vercel. Learn how in the section below.
For optimal performance, choose a data source which:
- Has optimal cold-boot performance. That means it should respond quickly upon initial connection)
- Has optimal connection pooling. That means it can handle spikes in concurrent connections
The default Function region is Washington, D.C., USA (
iad1) for all new projects. Many of the most popular database and infrastructure providers deploy to this region by default, so this ensures your Functions will deliver fast responses out of the box in most cases.
sfo1). We recommend updating these projects to the new default of Washington, D.C., USA (
This default region will apply project-wide to Serverless Functions, and can be configured in your project's Dashboard settings on Vercel. Follow the instructions below to do so:
- Choose the appropriate project from your Dashboard on Vercel
- Navigate to the Settings tab near the top of the Dashboard page
- A set of options will appear on the left side. Select Functions.
- Use the Function Region dropdown setting to select which Edge Region you want to use as your project's default
We highly recommend selecting the region closest to the data infrastructure your Functions depend on.
If you want to override your default region, you can do so in two ways:
- With your
vercel.jsonconfiguration file. Add your region to the
"regions"key. Learn more about adding regions in our
- With the Vercel CLI. Use the
vercel --regionscommand in your project's root directory to set a region. Learn more about setting regions with the
vercel --regionscommand in our CLI docs.
Multiple Serverless Function regions are only allowed for Enterprise accounts. If your Project requires more than one Serverless Function region, please contact Sales.