Back to Remotion

Data transfer cost

packages/docs/docs/lambda/data-transfer-cost.mdx

4.0.4833.4 KB
Original Source

When rendering on Remotion Lambda, a headless browser is opened, which opens your bundle via the Serve URL.
Your site and assets are being loaded via HTTP, meaning that you will be charged by AWS for the data transfer.

If you have big assets, these charges may add up.
This site explains three options for reducing the cost if you have big assets.

Isn't data transfer free if the assets are in the same region?

No, with the default settings, since the transfer happens over HTTP, AWS counts this as egress, even if the assets are in the same S3 region.

Option 1: Use an alternate CDN for storing assets

Many Remotion users use Cloudflare R2 to store their big assets instead.
This is easy to achieve - simply put the assets in a Cloudflare R2 bucket and reference them using the HTTP URL that you get.

Cloudflare does not charge for data transfer, so this is a great way to reduce the cost.

Enable Cloudflare Cache for R2 assets

If you serve videos or audio files from R2, also make sure that Cloudflare Cache is enabled for the bucket. Cold reads from R2 can be slower than cached reads, especially when @remotion/media fetches a video through byte range requests.

Use a custom domain for the R2 bucket and configure a Cloudflare Cache Rule for the asset URLs. The r2.dev development URL does not support caching.

After enabling the rule, inspect the response headers for your media URL:

  • CF-Cache-Status: HIT or MISS means the request went through Cloudflare Cache.
  • CF-Cache-Status: DYNAMIC means the request was not served from cache.

See Cloudflare's cache response documentation for the possible values.

Make sure to disable the Bot fight mode for R2:

  • Go to Security of your domain -> Settings -> disable "Bot fight mode"
  • Ensure you use your own domain on the bucket

This ensures no traffic gets blocked when the Lambda function uses a headless browser to load the assets.

Option 2: Use @remotion/media tags

The <Video /> and <Audio /> components from @remotion/media support partial downloads of media files. Unlike <OffthreadVideo />, which needs to download the entire file before extracting a frame, the @remotion/media tags use byte range requests to only fetch the parts of the file that are needed.

This means that if your composition only uses a portion of a large video, the Lambda function will not download the full file — significantly reducing data transfer.

See the comparison of video tags for a full feature comparison.

Option 3: Enable VPC endpoints

You can with some configuration set up a VPC for the Lambda function.

Refer to these notes for how to enable VPC endpoints for Remotion Lambda.

Caveats

  • If a Lambda function already existed, this will not update the settings. Delete the Remotion Lambda function and redeploy a new one.
  • You still pay a flat fee per request.
  • Setting up a VPC endpoint might restrict other network traffic.
  • We do not have recommendations yet for how to configure the VPC endpoint.

See also