Manage and optimize usage for Edge Functions
Learn how to understand the different charts in the Vercel dashboard, how usage relates to billing, and how to optimize your Edge Functions usage.The Edge Functions section shows the following charts:
You are charged based on the number of times your functions get invoked. This includes both successful and errored invocations, but does not include cache hits. The number of invocations is calculated based on the number of times your function gets called, regardless of the response status code.
When viewing your Invocations graph, you can group by Count to see the total of all invocations across your team's projects.
- Use the Projects option to see the total number of invocations for each project within your team. This can help you identify which projects are using the most invocations happen and where you can optimize
- Cache your responses using edge caching and Cache-Control headers. This can help reduce the number of invocations that your Functions receive and makes responses faster for users
You are charged based on number of execution units that your Edge Functions have used. Vercel will work out the number of execution units (total CPU time of the invocation / 50ms) used for each invocation. You will then be charged based on anything over the limit.
Each invocation of an Edge Function has a Total CPU time, which is the time spent actually running your code. It doesn't include execution time such as spent waiting for data fetches to return.
For example:
- If your function gets invoked 250,000 times and uses 350 ms of CPU time at each invocation, then the function will incur (350 ms / 50 ms) = 7 execution units each time the function gets invoked.
- Your usage is: 250,000 * 7 = 1,750,000 execution units
- As a Pro user you have 1,000,000 execution units included in your plan, so you will be charged for the additional 750,000 execution units. That's $2.00 for each additional 1,000,000 execution units
- Execution units are comprised of a calculation of invocation count and CPU time. You can optimize your Edge Functions by reducing the number of invocations through caching and the CPU time used per invocation
There is no time limit on the amount of CPU time your Edge Function can use during a single invocation. However, you are charged for each execution unit, which is based on the compute time. The compute time refers to the actual net CPU time used, not the execution time. Operations such as network access do not count towards the CPU time.
You can view CPU time by Average to show the average time for computation across all projects using Edge Functions within your team. This data point provides an idea of how long your Edge Functions are taking to compute responses to requests and can be used in combination with the invocation count to calculate execution units.
- View the CPU time by Project to understand which Projects are using the most CPU time
- CPU time is calculated based on the actual time your function is running, not the time it takes to respond to a request. Therefore you should optimize your code to ensure it's as performant as possible and avoid heavy CPU-bound operations
Was this helpful?