Skip to content

🎥 Make videos programmatically with React

allow to pass in memorySize

Jonny Burgerff3c9cf3a922
diff --git a/packages/docs/docs/deploylambda.md b/packages/docs/docs/deploylambda.md
index 1c8be51702..52724dc908 100644
--- a/packages/docs/docs/deploylambda.md
+++ b/packages/docs/docs/deploylambda.md
@@ -19,7 +19,8 @@ const {layerArn} = await ensureLambdaBinaries('us-east-1');
const {functionName} = await deployLambda({
layerArn,
region: 'us-east-1',
- timeoutInSeconds: 120
+ timeoutInSeconds: 120,
+ memorySize: 1024
});
console.log(functionName)
```
@@ -41,6 +42,10 @@ The AWS region which you want to deploy the Lambda function too. It must be the
How long the Lambda function may run before it gets killed. Must be below 900 seconds.
We recommend a timeout of 120 seconds or lower - remember, Remotion Lambda is the fastest if you render with a high concurrency. If your video takes longer to render, the concurrency should be increased rather than the timeout.
+## `memorySize`
+
+How many megabytes of RAM the Lambda function should have. By default we recommend a value of 1024MB. You may increase or decrease it depending on how memory-consuming your video is. The minimum allowed number is `512`, the maximum allowed number is `10240`. Since the costs of Remotion Lambda is directly proportional to the amount of RAM, we recommend to keep this amount as low as possiblr.
+
## Return value
An object with the following values:
diff --git a/packages/lambda/src/api/deploy-lambda.ts b/packages/lambda/src/api/deploy-lambda.ts
index 7603e76376..a5c7c1a468 100644
--- a/packages/lambda/src/api/deploy-lambda.ts
+++ b/packages/lambda/src/api/deploy-lambda.ts
@@ -3,7 +3,7 @@ import {CreateFunctionCommand} from '@aws-sdk/client-lambda';
import {readFileSync} from 'fs';
import {AwsRegion} from '../pricing/aws-regions';
import {getIamClient, getLambdaClient} from '../shared/aws-clients';
-import {MEMORY_SIZE, RENDER_FN_PREFIX} from '../shared/constants';
+import {RENDER_FN_PREFIX} from '../shared/constants';
import {randomHash} from '../shared/random-hash';
import {bundleLambda} from './bundle-lambda';
@@ -11,7 +11,9 @@ export const deployLambda = async (options: {
region: AwsRegion;
layerArn: string;
timeoutInSeconds: number;
+ memorySize: number;
}) => {
+ // TODO: Validate memory size
// TODO: Validate parameters and enforce timeout below 900 seconds.
const fnNameRender = RENDER_FN_PREFIX + randomHash();
const [renderOut, user] = await Promise.all([
@@ -36,7 +38,7 @@ export const deployLambda = async (options: {
Role: `arn:aws:iam::${accountId[1]}:role/remotion-lambda-role`,
Runtime: 'nodejs14.x',
Description: 'Renders a Remotion video.',
- MemorySize: MEMORY_SIZE,
+ MemorySize: options.memorySize,
Timeout: options.timeoutInSeconds,
Layers: [options.layerArn],
})
diff --git a/packages/lambda/src/cli/deploy.ts b/packages/lambda/src/cli/deploy.ts
index 957abb11ee..88689c4bcb 100644
--- a/packages/lambda/src/cli/deploy.ts
+++ b/packages/lambda/src/cli/deploy.ts
@@ -8,11 +8,14 @@ export const DEPLOY_COMMAND = 'deploy';
export const deployCommand = async () => {
// TODO: Unhardcode timeout
const TIMEOUT_HARDCODED = 120;
+ // TODO: Unhardcode memory
+ const MEMORY_SIZE = 1024;
const {layerArn} = await ensureLambdaBinaries(getAwsRegion());
const {functionName} = await deployLambda({
region: getAwsRegion(),
timeoutInSeconds: TIMEOUT_HARDCODED,
layerArn,
+ memorySize: MEMORY_SIZE,
});
Log.info(`Deployed to ${functionName}`);
};
diff --git a/packages/lambda/src/run.ts b/packages/lambda/src/run.ts
index 3874431861..36bc78c1b8 100644
--- a/packages/lambda/src/run.ts
+++ b/packages/lambda/src/run.ts
@@ -43,6 +43,7 @@ const getFnName = async (options: {
region: getAwsRegion(),
timeoutInSeconds: 120,
layerArn,
+ memorySize: 1024,
});
const {url} = await deployProject({