packages/docs/docs/lambda/separate-environments.mdx
The code that is inside the Lambda function is always the same, no matter if you are calling it from a local, staging or production environment.
Also, each render executed with Remotion Lambda is completely isolated from another, in terms of compute and storage.
Each Lambda function has a configuration that determines its unique name:
If you have the same configuration in different environments, you can safely re-use the same function since each execution is isolated – in fact, duplicating the function is not supported because it achieves nothing.
If you are changing the configuration in one environment, deploy a new function and leave the old one deployed.
This allows you to safely test new functions without breaking the other environments.
You don't incur any costs for functions that are deployed but not used.
We recommend to scope the site to a specific environment using --site-name when creating a site. For example, use --site-name=remotion-production and --site-name=remotion-staging.
A site contains your React / Remotion code and might change frequently.
Make sure to update your site whenever you make changes to your code or upgrade Remotion, and to not use the site for other environments if they differ.
Just one bucket per region can be used for Remotion Lambda, but the resources in it can be scoped.
A bucket contains 2 folders:
sites/ folder for your sitesrenders/ folder for your rendersYou should scope your sites option when creating a site.
The renders are automatically scoped when rendering by creating subfolders with unique IDs within the renders/ folder.
It is safe to use the same bucket for all environments.
Use the privacy option to make renders private.
The sites must be public because they are accessed via HTTP.
npx remotion lambda render command looks for functions that match this convention.speculateFunctionName() function save one API call.A function is not tied to a project.
Each function is a binary that contains the same code.
Every Remotion Lambda user runs the exact same code in their function.
The React code you write is not contained in the function, it is hosted on the Serve URL.
Each function invocation is isolated and they cannot conflict each other. There is a concurrency limit, but it is per region, not per function.
Function invocations don't conflict each other.
Functions also don't contain any code that you write, they are binary and every Remotion Lambda user runs the exact same code.
It is impossible for a bad staging deployment to affect the production function.
Therefore, we recommend to use the same function for all environments.
This is supported! You can have multiple functions with different configurations.
It is only not possible to have multiple functions that share the exact same configuration:
To distinguish which function should be used, pass the function name explicitly to renderMediaOnLambda().
You can pass --function-name to npx remotion lambda render
It is possible deploy multiple sites under different Serve URLs.
This convention only applies to functions, which do not contain any code that you write.
You do not need to do this, because you can invoke a function multiple times concurrently.
There is no concurrency limit per function, but a concurrency limit per region and account.
Therefore there is no benefit in having multiple identical functions in the same region and account for load-balancing.