documentation
documentation copied to clipboard
Guidance for deploying TypeScript Workers
Brief description
Each SDK should have different guidance on deploying workers. I think it should be part of the dev guide, as it's something all developers will need to do (or at least someone on your team will need to set it up and monitor it, similar to metrics/tracing).
Your recommended content
There are a number of ways to run your Worker code in production and scale it to meet your production load.
What about serverless? Workers are stateful, long-running processes: they poll for tasks and keep a cache of active Workflow Executions in order to reduce resource consumption and latency. Therefore they cannot be run in AWS Lambdas or other serverless environments. You can, however, call serverless functions from your Activities.
- pre-deploy checklist:
- prod cluster, update connection strings/keys/namespaces
- suggest setting up metrics/tracing/logging/testing (links to other sections)
- lang-specific items, like pre-build code in TS and info from this thread on CPU-intensive tasks in node and RAM/workflow cache thrashing
- services like Render
- docker image, like https://legacy-documentation-sdks.temporal.io/typescript/production-deploy#running-in-docker
- managing pool of containers. maybe @mjameswh has content for an ECS section
content on building code:
Pre-build code
In most of our samples:
- We use
ts-node, which compiles TypeScript on the fly. - Our Workers bundle Workflow code at runtime.
We can improve our Worker's startup time by building code in advance.
Worker code
The Worker code can be built and run with:
npm run build
node lib/worker.js
Workflow code
See bottom part of this section.
Can include this env vars file: https://github.com/temporalio/documentation/pull/1948