Skip to content

🎥 Make videos programmatically with React

memory now memoryLimit, cpu now cpuLimit

Matt McGillivray2ad77c49ec48
diff --git a/packages/cloudrun/src/api/check-if-service-exists.ts b/packages/cloudrun/src/api/check-if-service-exists.ts
index ad455a1708..9e6fe36cb8 100644
--- a/packages/cloudrun/src/api/check-if-service-exists.ts
+++ b/packages/cloudrun/src/api/check-if-service-exists.ts
@@ -7,8 +7,8 @@ import {validateProjectID} from '../shared/validate-project-id';
import {getCloudRunClient} from './helpers/get-cloud-run-client';
export type CheckIfServiceExistsInput = {
- memory: string;
- cpu: string;
+ memoryLimit: string;
+ cpuLimit: string;
projectID: string;
region: string;
};
@@ -30,8 +30,8 @@ export const checkIfServiceExists = async (
const parent = `projects/${options.projectID}/locations/${options.region}`;
const serviceName = generateServiceName({
- memory: options.memory,
- cpu: options.cpu,
+ memoryLimit: options.memoryLimit,
+ cpuLimit: options.cpuLimit,
});
const cloudRunClient = getCloudRunClient();
diff --git a/packages/cloudrun/src/api/deploy-service.ts b/packages/cloudrun/src/api/deploy-service.ts
index 9e1872aed0..44c61f22dc 100644
--- a/packages/cloudrun/src/api/deploy-service.ts
+++ b/packages/cloudrun/src/api/deploy-service.ts
@@ -8,8 +8,8 @@ import {getCloudRunClient} from './helpers/get-cloud-run-client';
export type DeployServiceInput = {
remotionVersion: string;
- memory?: string;
- cpu?: string;
+ memoryLimit?: string;
+ cpuLimit?: string;
projectID: string;
region: string;
};
@@ -36,12 +36,12 @@ export const deployService = async (
validateProjectID(options.projectID);
validateRemotionVersion(options.remotionVersion);
- if (!options.memory) {
- options.memory = '512Mi';
+ if (!options.memoryLimit) {
+ options.memoryLimit = '512Mi';
}
- if (!options.cpu) {
- options.cpu = '1.0';
+ if (!options.cpuLimit) {
+ options.cpuLimit = '1.0';
}
const parent = `projects/${options.projectID}/locations/${options.region}`;
@@ -49,15 +49,15 @@ export const deployService = async (
const cloudRunClient = getCloudRunClient();
const existingService = await checkIfServiceExists({
- memory: options.memory,
- cpu: options.cpu,
+ memoryLimit: options.memoryLimit,
+ cpuLimit: options.cpuLimit,
projectID: options.projectID,
region: options.region,
});
const serviceName = generateServiceName({
- memory: options.memory,
- cpu: options.cpu,
+ memoryLimit: options.memoryLimit,
+ cpuLimit: options.cpuLimit,
});
if (existingService) {
@@ -75,8 +75,8 @@ export const deployService = async (
// service structure: https://googleapis.dev/nodejs/run/latest/google.cloud.run.v2.IService.html
template: constructServiceTemplate({
remotionVersion: options.remotionVersion,
- memory: options.memory,
- cpu: options.cpu,
+ memoryLimit: options.memoryLimit,
+ cpuLimit: options.cpuLimit,
}),
},
serviceId: serviceName,
diff --git a/packages/cloudrun/src/api/helpers/construct-service-deploy-request.ts b/packages/cloudrun/src/api/helpers/construct-service-deploy-request.ts
index 16f5992c31..287a9523b7 100644
--- a/packages/cloudrun/src/api/helpers/construct-service-deploy-request.ts
+++ b/packages/cloudrun/src/api/helpers/construct-service-deploy-request.ts
@@ -1,11 +1,11 @@
export const constructServiceTemplate = ({
remotionVersion,
- memory,
- cpu,
+ memoryLimit,
+ cpuLimit,
}: {
remotionVersion: string;
- memory: string;
- cpu: string;
+ memoryLimit: string;
+ cpuLimit: string;
}) => {
return {
containers: [
@@ -13,8 +13,8 @@ export const constructServiceTemplate = ({
image: `us-docker.pkg.dev/remotion-dev/cloud-run/render:${remotionVersion}`,
resources: {
limits: {
- memory,
- cpu,
+ memory: memoryLimit,
+ cpu: cpuLimit,
},
},
},
diff --git a/packages/cloudrun/src/cli/commands/services/deploy.ts b/packages/cloudrun/src/cli/commands/services/deploy.ts
index 642e06c277..951f0ec666 100644
--- a/packages/cloudrun/src/cli/commands/services/deploy.ts
+++ b/packages/cloudrun/src/cli/commands/services/deploy.ts
@@ -18,11 +18,11 @@ export const cloudRunDeploySubcommand = async () => {
const remotionVersion = VERSION;
const allowUnauthenticated =
parsedCloudrunCli['allow-unauthenticated'] ?? false;
- let memory = parsedCloudrunCli.memory ?? '512Mi';
- let cpu = parsedCloudrunCli.cpu ?? '1.0';
+ let memoryLimit = parsedCloudrunCli.memoryLimit ?? '512Mi';
+ let cpuLimit = parsedCloudrunCli.cpuLimit ?? '1.0';
- memory = String(memory);
- cpu = String(cpu);
+ memoryLimit = String(memoryLimit);
+ cpuLimit = String(cpuLimit);
if (!CliInternals.quietFlagProvided()) {
Log.info(
@@ -31,8 +31,8 @@ export const cloudRunDeploySubcommand = async () => {
Validating Deployment of Cloud Run Service:
Remotion Version = ${remotionVersion}
- Service Memory Limit = ${memory}
- Service CPU Limit = ${cpu}
+ Service Memory Limit = ${memoryLimit}
+ Service CPU Limit = ${cpuLimit}
Project Name = ${projectID}
Region = ${region}
Allow Unauthenticated Access = ${allowUnauthenticated}
@@ -56,8 +56,8 @@ Validating Deployment of Cloud Run Service:
try {
const deployResult = await deployService({
remotionVersion,
- memory,
- cpu,
+ memoryLimit,
+ cpuLimit,
projectID,
region,
});
@@ -115,8 +115,8 @@ Validating Deployment of Cloud Run Service:
Log.error(
CliInternals.chalk.red(
`Failed to deploy service - ${generateServiceName({
- memory,
- cpu,
+ memoryLimit,
+ cpuLimit,
})}.`
)
);
diff --git a/packages/cloudrun/src/shared/generate-service-name.ts b/packages/cloudrun/src/shared/generate-service-name.ts
index 2a99ac4cf7..0da061dd86 100644
--- a/packages/cloudrun/src/shared/generate-service-name.ts
+++ b/packages/cloudrun/src/shared/generate-service-name.ts
@@ -2,15 +2,15 @@ import {RENDER_SERVICE_PREFIX} from './constants';
import {SERVICE_VERSION_STRING} from './service-version-string';
export const generateServiceName = ({
- memory,
- cpu,
+ memoryLimit,
+ cpuLimit,
}: {
- memory: string;
- cpu: string;
+ memoryLimit: string;
+ cpuLimit: string;
}): string => {
- const sanitisedCPU = cpu.replace(/\./g, '-').substring(0, 10);
+ const sanitisedCPU = cpuLimit.replace(/\./g, '-').substring(0, 10);
- const sanitisedMem = memory
+ const sanitisedMem = memoryLimit
.replace(/\./g, '-')
.substring(0, 10)
.toLowerCase();
diff --git a/packages/docs/docs/cloudrun/deployservice.md b/packages/docs/docs/cloudrun/deployservice.md
index 5b14982ec9..ad17fdf2e1 100644
--- a/packages/docs/docs/cloudrun/deployservice.md
+++ b/packages/docs/docs/cloudrun/deployservice.md
@@ -20,8 +20,8 @@ import { deployService } from "@remotion/cloudrun";
const { shortName } = await deployService({
remotionVersion: "3.3.82",
- memory: "2GiB",
- cpu: "2.0",
+ memoryLimit: "2Gi",
+ cpuLimit: "2.0",
projectID: "my-remotion-project",
region: "us-east1",
});
@@ -36,11 +36,11 @@ An object with the following properties:
The Remotion version of the service. Remotion is versioning the Cloud Run service and a render can only be triggered from a version of `@remotion/cloudrun` that is matching the one of the service.
-### `memory`
+### `memoryLimit`
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.
-### `cpu`
+### `cpuLimit`
The maximum number of CPU cores that the Cloud Run service can use to process requests.
diff --git a/packages/docs/docs/cloudrun/getServiceinfo.md b/packages/docs/docs/cloudrun/getServiceinfo.md
index 505c465a5e..aa8123f1b8 100644
--- a/packages/docs/docs/cloudrun/getServiceinfo.md
+++ b/packages/docs/docs/cloudrun/getServiceinfo.md
@@ -26,7 +26,7 @@ const info = await getServiceInfo({
});
console.log(info.serviceName); // remotion--3-3-82--mem512mi--cpu1-0
console.log(info.timeoutInSeconds); // 120
-console.log(info.memoryLImit); // 1500
+console.log(info.memoryLimit); // 1500
console.log(info.cpuLimit); // 2048
console.log(info.remotionVersion); // '2021-07-14'
```
@@ -46,9 +46,9 @@ The name of the service.
## Return value
If the service does not exist, an error is thrown by the GCP SDK.
-If the service exists, promise resolving to an object with the following properties is returned:
+If the service exists, a promise resolving to an object with the following properties is returned:
-### `memoryLImit`
+### `memoryLimit`
The upper bound on the amount of RAM that the Cloud Run service can consume.