Amazon Cloudfront Functions logo

Amazon Cloudfront Functions

Lightweight Functions Close to the End-User

Amazon Cloudfront Functions Overview

Core Product

Functions Edge Compute
Free Tier

Information Resources

Amazon Cloudfront Functions Homepage
Amazon Cloudfront Functions Homepage

What is Amazon Cloudfront Functions?

With Functions, Amazon Cloudfront CDN (Content Delivery Network) introduced cloud computing to every CloudFront PoP around the globe in 2021. This means you can run your functions directly at the edge of Amazon’s network, a proximity to end-users that can significantly reduce latency. With this change in approach, Amazon aims to further strengthen its position in the emerging space of IaaS (Infrastructure as a Service) and serverless computing at the edge. Given Amazon’s massive reach and the tremendously popular CloudFront product, this will surely be a success going forward.

Focus

CloudFront Functions is designed for basic, short-running tasks such as cache key normalization, header manipulation, URL redirects or rewrites, and request authorization. The latest JavaScript 2.0 runtime environment is specifically optimized for high performance and low latency.

Functions does not provide a full Node.js environment, so users won’t have access to libraries or modules, just plain JavaScript. But, you can use the global, low-latency CloudFront KeyValueStore to store and retrieve lookup data from within CloudFront Functions.

Limitations

The quotas are intentionally low, allowing only for small optimized scripts that run for brief durations. The maximum execution time is a reported 1 milisecond, although the official Amazon documentation is not clear about this and only states that: ‘CloudFront Functions have a limit on the time they can take to run, measured as compute utilization. Compute utilization is a number between 0 and 100 that indicates the amount of time that the function took to run as a percentage of the maximum allowed time’.

This execution limitation enables Cloudfront Functions to handle millions of requests per second with sub-millisecond startup times, making them ideal for latency-sensitive tasks. We will test the actual metrics ourselves in the near future and report our findings here.

CloudFront Functions don’t have the capability to access the internet, as the infrastructure is designed for lightweight operations that execute quickly at the edge. CloudFront Functions also can’t access the filesystem, which limits their use to simple request and response manipulations.

CloudFront Functions or AWS Lambda@Edge?

AWS Lambda@Edge provides more runtime options, supports dependencies, and allows functions to access the internet. Since recently, Lambda@Edge functions are executed within CloudFront’s CDN edge network, as well as AWS’s broader network, which can include execution within customers’ VPNs or behind load balancers.

Service Types

Functions
Available
Edge Compute
Available

Functions Runtimes

JavaScript
Available

Execution Limits and Resource Quotas

Min. Memory
2 MB
Max. Memory
2 MB
Default Timeout
Max. Timeout
~1 ms
Request Payload
10 KB
Response Payload
10 KB
An interactive map displaying all 57 Amazon Cloudfront Functions datacenters by region.

Alternatives to Amazon Cloudfront Functions are generated by matching platform type and supported runtimes