Capítulo 446 de 988

Chapter 446: Concurrency

Core Idea

Remotion Lambda is a highly concurrent distributed video rendering system. That means that the video rendering work is split up across many Lambda functions.

Key Concepts

  • Setting the concurrency
  • Default values
  • Concurrency limits
  • "Too many functions"

Code Examples

const bestFramesPerLambdaParam = (frameCount: number) => {
  // Between 0 and 10 minutes (at 30fps), interpolate the concurrency from 75 to 150
  const concurrency = interpolate(frameCount, [0, 18000], [75, 150], {
    extrapolateRight: 'clamp',
  });

  // At least have 20 as a `framesPerLambda` value
  const framesPerLambda = Math.max(frameCount / concurrency, 20);

  // Evenly distribute: For 21 frames over 2 lambda functions, distribute as 11 + 10 ==> framesPerLambda = 11
  const lambdasNeeded = Math.ceil(frameCount / framesPerLambda);

  return Math.ceil(frameCount / lambdasNeeded);
};
  • What it demonstrates: Usage pattern for Concurrency from the official docs.

Key Takeaways

  1. Understand setting the concurrency when working with Concurrency.
  2. Understand default values when working with Concurrency.
  3. Understand concurrency limits when working with Concurrency.
  4. Understand "too many functions" when working with Concurrency.

Connects To

  • api: related page in the Lambda (@remotion/lambda) section.
  • Approuterwebhook: related page in the Lambda (@remotion/lambda) section.
  • Authentication: related page in the Lambda (@remotion/lambda) section.