Skip to content
← Back to Blog

Friday, July 5th 2024

Understanding Vercel Functions

Posted by

Avatar for leerob

Lee Robinson

VP of Product

Vercel Functions run code in response to user traffic without the need to manage your own infrastructure, provision servers, or manage hardware.

This can provide some advantages over traditional infrastructure, including:

Secure and always up-to-date environments

With traditional infrastructure, you need to ensure your servers are properly configured, patched, and monitored for vulnerabilities. This can be additional maintenance work (especially for small teams or individual developers) or downtime (to install updates and restart the server).

For example, this is similar to running and managing a WordPress instance versus using a fully managed service.

With Vercel Functions, every workload is isolated to minimize the attack surface area of a malicious actor. The underlying infrastructure like the OS, kernel, and hypervisor layers are patched automatically. Node.js runtime updates are released automatically, including critical security vulnerability patches.

Vulnerability surface

Vercel ensures your compute is always running on a secure, up-to-date environment, protected against vulnerabilities.

Layer

Vercel

Virtual Private Server (VPS)

OS

Vercel Managed

Customer Managed

Runtime

Vercel Managed

Customer Managed

Hypervisor

Vercel Managed

VPS Managed

User Code

Customer Managed

Customer Managed

Learn more about our shared responsibility model. Enterprise customers can also purchase dedicated, isolated build and compute through Vercel Secure Compute.

Predictable performance

With traditional infrastructure, you are responsible for managing and scaling resources to meet demand. Vercel Functions scale automatically based on incoming requests and don't compete for resources. This eliminates the risk of queuing on the event loop, which can affect the latency of your application.

Vercel's infrastructure scales automatically based on demand.
Vercel's infrastructure scales automatically based on demand.
Vercel's infrastructure scales automatically based on demand.
Vercel's infrastructure scales automatically based on demand.

While this scalability is beneficial, it must also be paired with spend controls and observability into usage.

For optimal performance, Vercel Functions are powered by Rust and have advanced bytecode caching. This makes startup times faster and more consistently low-latency.

Up to 80ms faster (average) and 500ms faster (p99) for larger workloads by moving logic from Node.js to the new Rust-powered core.
Up to 80ms faster (average) and 500ms faster (p99) for larger workloads by moving logic from Node.js to the new Rust-powered core.
Up to 80ms faster (average) and 500ms faster (p99) for larger workloads by moving logic from Node.js to the new Rust-powered core.
Up to 80ms faster (average) and 500ms faster (p99) for larger workloads by moving logic from Node.js to the new Rust-powered core.
Up to 80ms faster (average) and 500ms faster (p99) for larger workloads by moving logic from Node.js to the new Rust-powered core.
Up to 80ms faster (average) and 500ms faster (p99) for larger workloads by moving logic from Node.js to the new Rust-powered core.
Up to 80ms faster (average) and 500ms faster (p99) for larger workloads by moving logic from Node.js to the new Rust-powered core.
Up to 80ms faster (average) and 500ms faster (p99) for larger workloads by moving logic from Node.js to the new Rust-powered core.

High availability

Vercel Functions provide high availability out of the box.

You don't need to worry about server failures or downtime, as functions scale and failover automatically across availability zones (and even regions). Further, features like Instant Rollback and Skew Protection provide more ways to ensure your site is always online.

This level of resilience requires a large investment in infrastructure and monitoring when maintaining your own infrastructure.

Automatic downscaling and deprovisioning

Vercel Function can handle extremely variable traffic patterns, scaling up to 30,000 concurrent requests (or 100,000+ on Enterprise) without any manual intervention. This makes functions a great choice for ecommerce, media sites, or startup launches that are likely to attract lots of attention.

Traditional infrastructure can provide some cost efficiencies, with dedicated servers allowing unlimited data transfer for a fixed price. This does, however, require maintenance and manual management. After reaching the limits of the current infrastructure you have provisioned, you need to purchase (or rent) larger hardware.

Running compute that scales on demand (and back down to zero) allows you to have more granular control over your spend. You only pay for the resources you use during a large traffic event and then return to your baseline spend, without needing to change your underlying hardware setup.

Vercel creates cloud infrastructure based on your framework code. This flexibility, combined with our infinite preview environments, means you can quickly and easily spin up new compute infrastructure to test your next big idea.

And when you're done? Don't worry about leaving compute running forever for an experiment. You can rest assured (with your site behind Deployment Protection) your usage (and cost) scales to zero.

Real-time usage and spend controls

Scalability shouldn't come at the risk of "denial of wallet", which is why we provide recursion protection, spend controls, and an advanced Firewall.

While servers offer predictable spend, Vercel provides tools to control costs and avoid unexpected bills, while still enabling your business to handle unexpected traffic surges.

Spend Management.png
Spend Management (1).png

You can control the maximum duration functions run, monitor usage in real time, block traffic patterns, and set both soft and hard limits based on your spend. These alerts can be sent in the Vercel dashboard, through email, or even SMS. This visibility and control allows you to optimize your usage and keep costs under control.

Out-of-the-box observability

Infrastructure platforms usually require you to choose your own tools for observability.

While this allows flexibility, it does require more configuration and potentially vendoring solutions to understand runtime performance, errors, and logs.

Vercel Functions integrate with our observability suite for build and runtime logs, advanced traffic monitoring, and the ability to drain logs to external services if you prefer.

Quickly identify the root cause of persistent errors and customer issues with Logs.
Quickly identify the root cause of persistent errors and customer issues with Logs.
Quickly identify the root cause of persistent errors and customer issues with Logs.
Quickly identify the root cause of persistent errors and customer issues with Logs.

We have also integrated support for OpenTelemetry (OTEL) tracing. When viewing runtime logs, you can view the status, duration, URL, and even metrics for outgoing requests.

Screenshot of new requests metrics, showing 5 outgoing fetch requests with traces on the side
Screenshot of new requests metrics, showing 5 outgoing fetch requests with traces on the side
Screenshot of new requests metrics, showing 5 outgoing fetch requests with traces on the side
Screenshot of new requests metrics, showing 5 outgoing fetch requests with traces on the side

Summary

With automatic scaling, high availability, cost efficiency, and built-in security, Vercel Functions abstract away many of the operational complexities associated with managing infrastructure.

This allows developers to focus on building great products without worrying about the underlying infrastructure. With Vercel's framework-defined infrastructure, developers can automatically use our scalable compute as defined by their frontend framework code.

Vercel Functions give you predictable CPU performance, the ability to run dynamic workloads in multiple regions, automatic SSL and encryption, integrated CI/CD into your Git workflow, preview environments, instant rollbacks, and more—and you can get started for free!

Learn more about Vercel Functions or get started building your first site.