🎥 Make videos programmatically with React
Docs: Add faster Lambda progress polling guide (#9507)
Jonny Burger8d51ba7aaf63
diff --git a/packages/docs/docs/lambda/faster-progress-polling.mdx b/packages/docs/docs/lambda/faster-progress-polling.mdxnew file mode 100644index 0000000000..732e943e9e--- /dev/null+++ b/packages/docs/docs/lambda/faster-progress-polling.mdx@@ -0,0 +1,40 @@+---+image: /generated/articles-docs-lambda-faster-progress-polling.png+title: Faster progress polling+slug: /lambda/faster-progress-polling+crumb: 'Lambda'+---++By default, each [`getRenderProgress()`](/docs/lambda/getrenderprogress) call invokes the render function, which reads the render progress from S3.++Set [`skipLambdaInvocation`](/docs/lambda/getrenderprogress#skiplambdainvocation) to `true` to read the progress directly from S3 instead. This reduces the latency and avoids a Lambda invocation for each progress poll. It does not make the render itself faster.++```ts twoslash title="poll-progress.ts"+import {getRenderProgress, speculateFunctionName} from '@remotion/lambda/client';++const functionName = speculateFunctionName({+ memorySizeInMb: 2048,+ diskSizeInMb: 2048,+ timeoutInSeconds: 120,+});++const progress = await getRenderProgress({+ renderId: 'd7nlc2y',+ bucketName: 'remotionlambda-useast1-abcdefgh',+ functionName,+ region: 'us-east-1',+ skipLambdaInvocation: true,+});+```++## Requirements++- The function name must follow the [Remotion function naming convention](/docs/lambda/naming-convention). Functions deployed using [`deployFunction()`](/docs/lambda/deployfunction) follow this convention.+- The AWS credentials calling [`getRenderProgress()`](/docs/lambda/getrenderprogress) must have `s3:GetObject` permission for the Remotion bucket. The policy returned by [`getUserPolicy()`](/docs/lambda/getuserpolicy) includes this permission.++If either requirement is not fulfilled, leave `skipLambdaInvocation` unset.++## See also++- [`getRenderProgress()`](/docs/lambda/getrenderprogress)+- [Optimizing Lambda for speed](/docs/lambda/optimizing-speed)diff --git a/packages/docs/docs/lambda/getrenderprogress.mdx b/packages/docs/docs/lambda/getrenderprogress.mdxindex 4e18ae4caf..34e12c5570 100644--- a/packages/docs/docs/lambda/getrenderprogress.mdx+++ b/packages/docs/docs/lambda/getrenderprogress.mdx@@ -7,7 +7,7 @@ crumb: 'Lambda API'---Gets the current status of a render initiated via [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda).-Calling this function results in a Lambda invocation.+By default, calling this function results in a Lambda invocation. See [Faster progress polling](/docs/lambda/faster-progress-polling) to read the progress directly from S3 instead.For renders initiated via [`renderStillOnLambda()`](/docs/lambda/renderstillonlambda), do not use this function. Instead, the result is returned immediately.@@ -63,7 +63,7 @@ Passes `forcePathStyle` to the AWS S3 client. If you don't know what this is, yo### `skipLambdaInvocation?`<AvailableFrom v="4.0.218" />Instead of calling a Lambda function which will get the progress from S3, make the S3 call directly.-This is cheaper and faster, but the function name must follow [the function name convention](/docs/lambda/naming-convention#see-also).+This is cheaper and faster, but requires additional permissions. Default: `false`. See [Faster progress polling](/docs/lambda/faster-progress-polling) for the requirements.## Responsediff --git a/packages/docs/docs/lambda/speed.mdx b/packages/docs/docs/lambda/speed.mdxindex d07294f6b5..7ae4ce7e94 100644--- a/packages/docs/docs/lambda/speed.mdx+++ b/packages/docs/docs/lambda/speed.mdx@@ -3,7 +3,7 @@ image: /generated/articles-docs-lambda-speed.pngid: optimizing-speedtitle: Optimizing for speedslug: /lambda/optimizing-speed-crumb: "Lambda"+crumb: 'Lambda'---On this page, a few strategies are presented for making a render on Lambda as fast as possible.@@ -25,6 +25,10 @@ The [`concurrencyPerLambda`](/docs/lambda/rendermediaonlambda#concurrencyperlambInstead of calling [`getFunctions()`](/docs/lambda/getfunctions), you can call [`speculateFunctionName()`](/docs/lambda/speculatefunctionname) to calculate the name of the function you are about to call to save an API call and save up to 1 second.+## Faster progress polling++[`getRenderProgress()`](/docs/lambda/getrenderprogress) can read progress directly from S3 instead of invoking a Lambda function for every poll. See [Faster progress polling](/docs/lambda/faster-progress-polling) for the benefits and requirements.+## Bucket namingIf you have a Remotion version before December 2022, then your bucket name might not include the region name in its name. This will result in Remotion having to list all bucket names and query their region before kicking off the render.diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.tsindex eb85aaaa93..bfc1f6bec6 100644--- a/packages/docs/sidebars.ts+++ b/packages/docs/sidebars.ts@@ -1293,6 +1293,7 @@ const sidebars: SidebarsConfig = {'lambda/bucket-naming','lambda/optimizing-cost','lambda/optimizing-speed',+ 'lambda/faster-progress-polling','lambda/proxy','lambda/limits','lambda/changelog',diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex dd6008b45b..236b9de62f 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -3266,6 +3266,15 @@ export const articles = [noAi: false,slug: 'lambda/faq',},+ {+ id: 'lambda/faster-progress-polling',+ title: 'Faster progress polling',+ relativePath: 'docs/lambda/faster-progress-polling.mdx',+ compId: 'articles-docs-lambda-faster-progress-polling',+ crumb: 'Lambda',+ noAi: false,+ slug: 'lambda/faster-progress-polling',+ },{id: 'feb-2022-outage',title: 'February 2022 Outage',diff --git a/packages/docs/static/generated/articles-docs-lambda-faster-progress-polling.png b/packages/docs/static/generated/articles-docs-lambda-faster-progress-polling.pngnew file mode 100644index 0000000000..8a0477b054Binary files /dev/null and b/packages/docs/static/generated/articles-docs-lambda-faster-progress-polling.png differ