How do I lower my Serverless Function execution time?

Learn how to lower your Serverless Function execution time.
Last updated on March 16, 2023
Functions

While deploying Serverless Functions on the Vercel platform, you may run into our Serverless Function Execution Timeout limit (seconds). This article covers steps you can take to lower your Serverless Function's execution time.

Here are some ideas to consider that can lower your Serverless Function's execution time:

  • Make sure to set your Serverless Function's region as close to your data source(s) as geographically possible.
  • What exactly is slow? The 3rd party API? If yes, can you trigger a request to the API and fetch the result later?
  • Introduce a caching layer between the 3rd party API and your Serverless Functions.
  • Move the workload to another environment; Reconsider if it would be better to offload work inside your Serverless Function to the client, etc.

As a general rule, Serverless Functions on Vercel should be lightweight helpers for frontend applications.

Couldn't find the guide you need?