deployService()
Cloud Run 处于 Alpha 状态,且尚未积极开发。
在你的 GCP 项目中创建一个 GCP Cloud Run 服务,该服务将能够在云端渲染视频。
🌐 Creates a GCP Cloud Run service in your GCP project that will be able to render a video in the cloud.
如果在指定区域中已经存在具有相同 Remotion 版本、内存限制、CPU 限制和超时时间的服务,则会返回该服务,而不会创建新的。这意味着该服务可以被视为幂等的。
🌐 If a service with the same Remotion version, memory limit, cpu limit and timeout already existed in the specified region, it will be returned instead without a new one being created. This means this service can be treated as idempotent.
示例
🌐 Example
import {deployService } from '@remotion/cloudrun';
const {shortName } = await deployService ({
memoryLimit : '2Gi',
cpuLimit : '2.0',
timeoutSeconds : 500,
projectID : 'my-remotion-project',
region : 'us-east1',
});
console .log (shortName );参数
🌐 Arguments
一个具有以下属性的对象:
🌐 An object with the following properties:
memoryLimit
Cloud Run 服务可以使用的最大 RAM 上限。默认情况下,我们推荐的值为 2GiB。你可以根据视频的内存消耗情况增减此值。允许的最小值为 512MiB,允许的最大值为 32GiB。由于 Remotion Cloud Run 的费用与 RAM 的使用量直接相关,我们建议将此数值保持尽可能低。随着内存限制的提高,必须遵守相应的 最小 CPU 限制。
🌐 The upper bound on the amount of RAM that the Cloud Run service can consume. By default we recommend a value of 2GiB. You may increase or decrease it depending on how memory-consuming your video is. The minimum allowed number is 512MiB, the maximum allowed number is 32GiB. Since the costs of Remotion Cloud Run is directly proportional to the amount of RAM, we recommend to keep this amount as low as possible. As the Memory limit is raised, there is a corresponding minimum CPU Limit that must be observed.
cpuLimit
Cloud Run 服务用于处理请求的最大 CPU 内核数。默认值为 1。随着 CPU 限制的提高,必须遵守相应的最小内存限制。
🌐 The maximum number of CPU cores that the Cloud Run service can use to process requests. The default is 1. As the CPU limit is raised, there is a corresponding minimum Memory Limit that must be observed.
minInstances
无论请求如何,必须可用的服务实例的最少数量。默认值为 0。一些用户可能希望增加最小实例数,以便渲染启动更快,但这只会将同时渲染的冷启动时间缩短到该最小限制。 在这里了解更多关于最小实例限制的信息
🌐 The minimum number of service instances to have available, regardless of requests. The default is 0. Some users may wish to increase the minimum instances so that renders are started faster, though this would only reduce cold start time for simultaneous renders up to that minimum limit. Read more about the minimum instance limit here
任何正在运行的实例,即使它们没有执行渲染,也将在 GCP 中计费。默认的最少实例数为零,这意味着当没有请求发送到你的服务时,你不会被收费。
maxInstances
GCP 可以根据传入请求创建的服务实例的最大数量。默认值是 100。在这里查看更多关于最大实例限制的信息
🌐 The maximum number of service instances that can be create by GCP in response to incoming requests. The default is 100. Read more about the maximum instance limit here
timeoutSeconds
Cloud Run 服务在被终止前可以运行多长时间。必须低于 3600 秒。
🌐 How long the Cloud Run Service may run before it gets killed. Must be below 3600 seconds.
projectID
已为 Remotion Cloud Run 配置的 GCP 项目的 项目 ID。
🌐 The project ID of the GCP Project that has been configured for Remotion Cloud Run.
region
你想要部署 Cloud Run 服务的 GCP 区域。
🌐 The GCP region which you want to deploy the Cloud Run Service too.
performImageVersionValidation
默认值为 true。这将验证公共 Artifact Registry 中是否存在与你尝试部署的 Remotion 版本匹配的镜像。可以设置为 false,以节省潜在的时间。
🌐 Default as true. This will validate that an image exists in the public Artifact Registry that matches the Remotion Version you are trying to deploy. Can be set false for a potential time saving.
onlyAllocateCpuDuringRequestProcessingv4.0.221
如果将此设置为 true,cpu_idle 将在服务清单中设置为 true。
在没有请求被处理时,CPU 分配将被禁用,这可能会带来显著的成本节省。
🌐 If this is set to true, cpu_idle will be set to true in the service manifest.
CPU alloction will be disabled while no request is being processed, which can lead to significant cost savings.
返回值
🌐 Return value
一个具有以下值的对象:
🌐 An object with the following values:
fullName(字符串): 刚创建的服务的全名,形式为projects/{projectId}/locations/{region}/services/{serviceName}。shortName(字符串): 刚创建的服务的名称,如控制台中所显示。uri(字符串): 刚创建的服务的端点。alreadyExists:(boolean): 创建是否被跳过,因为该服务已存在。
另请参阅
🌐 See also