documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Guidance for deploying TypeScript Workers

Open lorensr opened this issue 2 years ago • 2 comments

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

lorensr avatar Dec 29 '22 07:12 lorensr

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.

lorensr avatar Jan 03 '23 02:01 lorensr

Can include this env vars file: https://github.com/temporalio/documentation/pull/1948

lorensr avatar Mar 13 '23 19:03 lorensr