Skip to main content

estimatePrice()

根据 AWS Lambda 定价矩阵,计算指定区域、执行时长和内存大小的 AWS Lambda 所产生的费用。

🌐 Calculates the AWS costs incurred for AWS Lambda given the region, execution duration and memory size based on the AWS Lambda pricing matrix.

在渲染过程中,会生成许多 Lambda 函数:

🌐 During rendering, many Lambda functions are spawned:

  • 主函数会生成许多工作函数,等待分块渲染完成,然后将它们拼接在一起形成完整的视频。这是运行时间最长的 Lambda 函数。
  • 渲染函数渲染视频的一小部分,然后关闭。
  • 其他短暂且可以忽略的函数被启动用于初始化 lambda 和获取进度。

总持续时间是上述所有 Lambda 函数执行时间的总和。该持续时间可以传递给 estimatePrice() 来估算 AWS Lambda 的成本。

🌐 The total duration is the sum of execution duration of all of the above Lambda functions. This duration can be passed to estimatePrice() to estimate the cost of AWS Lambda.

计算出的持续时间不包括 S3 和 Remotion 许可费用。

🌐 The calculated duration does not include costs for S3 and Remotion licensing fees.

示例

🌐 Example

import { estimatePrice } from "@remotion/lambda";

console.log(
  estimatePrice({
    region: "us-east-1",
    durationInMilliseconds: 20000,
    memorySizeInMb: 2048,
    diskSizeInMb: 2048,
    lambdasInvoked: 1,
  })
); // 0.00067

参数

🌐 Arguments

一个包含以下参数的对象:

🌐 An object containing the following parameters:

region

Lambda 函数执行所在的区域。各区域价格有所不同

🌐 The region in which the Lambda function is executed in. Pricing varies across regions.

memorySizeInMb

已分配给 Lambda 函数的内存量。可以通过 getFunctionInfo() 获取。

🌐 The amount of memory that has been given to the Lambda function. May be received with getFunctionInfo().

durationInMilliseconds

所有 Lambda 总执行时间的估计值,以毫秒为单位。有关如何近似计算持续时间的指南,请参见本页顶部。

🌐 The estimated total execution duration in Milliseconds of all Lambdas combined. See the top of this page for a guide on how to approximate the duration.

lambdasInvoked

在渲染过程中被调用的 lambda 数量。

🌐 The number of lambdas that were invoked in the rendering process.

diskSizeInMb

分配的磁盘空间,以兆字节为单位。

🌐 The amount of disk space allocated in megabytes.

返回值

🌐 Return value

number 计算的预估成本(美元)。

🌐 The estimated cost in USD as a number.

另请参阅

🌐 See also