Skip to main content

地区选择

在使用 Remotion Lambda 上线之前,你需要考虑将你的函数和存储桶部署到哪个 AWS 区域。

🌐 Before going live with Remotion Lambda, you need to think about into which AWS region you are deploying your function and bucket.

本文件解释了如何选择一个区域以及你需要考虑哪些因素。

🌐 This document explains how to select a region and which considerations you need to make.

可用地区

🌐 Available regions

以下 AWS 区域可用:

🌐 The following AWS regions are available:

  • eu-central-1
  • eu-central-2
  • eu-west-1
  • eu-west-2
  • eu-west-3
  • eu-south-1
  • eu-north-1
  • us-east-1
  • us-east-2
  • us-west-1
  • us-west-2
  • af-south-1
  • ap-south-1
  • ap-east-1
  • ap-southeast-1
  • ap-southeast-2
  • ap-northeast-1
  • ap-northeast-2
  • ap-northeast-3
  • ap-southeast-4
  • ap-southeast-5
  • ca-central-1
  • me-south-1
  • sa-east-1

你可以调用 getRegions() 或输入 npx remotion lambda regions 来以编程方式获取此列表。

🌐 You can call getRegions() or type npx remotion lambda regions to get this list programmatically.

note

在 v3.3.7 中,已添加对地区 eu-west-3eu-south-1eu-north-1us-west-1af-south-1ap-east-1ap-northeast-2ap-northeast-3ca-central-1me-south-1sa-east-1 的支持。

默认区域

🌐 Default region

默认区域是 us-east-1

🌐 The default region is us-east-1.

选择一个区域

🌐 Selecting a region

有三种方式选择一个区域:

🌐 There are 3 ways to select a region:

  • 在使用 Node.JS API 时,你必须将区域明确传递给每个函数。确保你的项目符合 Typescript 类型或遵循文档。
  • 在使用 CLI 时,你可以使用 REMOTION_AWS_REGION 环境变量设置区域。最好将其放在 .env 文件中,以免忘记。
note

这个变量叫做 REMOTION_AWS_REGION,因为在像 Vercel 这样的云提供商中,AWS_REGION 是一个保留的环境变量名。然而,如果你在本地使用,Remotion 也接受后者。

  • 你也可以将 --region 标志传递给所有 CLI 命令以覆盖区域。该标志优先于环境变量。
note

在使用 Node.JS API 时,REMOTION_AWS_REGION 环境变量和 --region 标志不起作用。你需要显式传递一个区域。

如果你不设置区域,Remotion 将使用默认区域。

🌐 If you don't set a region, Remotion will use the default region.

我应该选择哪个地区?

🌐 Which region should I choose?

不同地区的定价不同。使用下表了解定价差异情况。

🌐 Different regions have different pricing. Use the following table to get a sense of the pricing differences.

数据可能已过时,请查阅 AWS Lambda 定价页面 获取最新信息。

🌐 Data may be out of date, please consult the AWS Lambda Pricing page for the latest information.

区域每 GB-秒 价格
ap-east-10.0000183000
af-south-10.0000176800
me-south-10.0000165334
eu-south-10.0000156138
ap-south-10.0000133334
ap-northeast-30.0000133334
ap-northeast-20.0000133334
ap-southeast-10.0000133334
ap-southeast-20.0000133334
ap-northeast-10.0000133334
ca-central-10.0000133334
eu-central-10.0000133334
eu-west-10.0000133334
eu-west-20.0000133334
eu-west-30.0000133334
eu-north-10.0000133334
sa-east-10.0000133334
us-east-10.0000133334
us-east-20.0000133334
us-west-10.0000133334
us-west-20.0000133334

之前,本节提到在一个区域内可以运行的并发 Lambda 数量有所不同。现在情况已经不再如此。

🌐 Previously, this section mentioned differences in the amount of concurrent lambdas that can be run in a region. This is no longer the case.

在 AWS 控制台中启用区域

🌐 Enabling regions in the AWS console

Remotion 支持的一些区域在 AWS 账户中默认未启用。如果你收到如下信息:

🌐 Some regions that are supported by Remotion are not enabled by default in an AWS account. If you get a message:

The security token included in the request is invalid

请参见这里

🌐 see here

其他考虑因素

🌐 Other considerations

  • 函数和 S3 存储桶必须位于同一个区域,以消除跨数据中心的延迟。不支持使用区域不匹配的函数和存储桶进行渲染
  • 你可以将整个架构部署到不同的区域,以进一步增加可以同时进行的渲染数量。这具有更高冗余性的优势,但潜在的缺点是可能会遇到非预热函数。
  • 有些地区比其他地区更贵(例如 af-south-1)。请查阅 AWS 的 Lambda 定价页面
  • 某些区域默认被禁用,你需要在 AWS 账户中启用它们才能使用。