Skip to content

perf(orchestrator): add POSTIZ_ACTIVE_PROVIDERS to limit idle Temporal workers#1651

Open
onyedikachi-david wants to merge 1 commit into
gitroomhq:mainfrom
onyedikachi-david:fix/temporal-idle-workers-postiz-active-providers
Open

perf(orchestrator): add POSTIZ_ACTIVE_PROVIDERS to limit idle Temporal workers#1651
onyedikachi-david wants to merge 1 commit into
gitroomhq:mainfrom
onyedikachi-david:fix/temporal-idle-workers-postiz-active-providers

Conversation

@onyedikachi-david

@onyedikachi-david onyedikachi-david commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Problem

On a standard Postiz deployment, getTemporalModule starts 32 Temporal workers (one per supported social provider + main), regardless of which integrations are actually configured. Each worker long-polls Temporal continuously, causing significant idle CPU/RAM overhead on every self-hosted instance.

From issue #1570, a deployment with only 8 configured integrations reports:

  • postiz container: ~27% CPU, 672 MiB RAM at idle
  • temporal container: ~31% CPU
  • temporal-elasticsearch: ~330 MiB
  • ~24 idle Postgres connections looping COMMIT

Root cause in temporal.module.ts:

workers: [
  { identifier: 'main', maxConcurrentJob: undefined },
  ...socialIntegrationList,          // all 31 providers
]
  .filter((f) => f.identifier.indexOf('-') === -1)
  .map((integration) => ({ autoStart: true, ... }))  // all start, always

Solution

Introduce an optional POSTIZ_ACTIVE_PROVIDERS environment variable — a comma-separated list of provider identifiers. When set, only those workers (plus the always-required main worker) are started.

# Only start workers for the 8 providers you actually use
POSTIZ_ACTIVE_PROVIDERS=twitter,instagram,linkedin,bluesky,telegram,facebook,threads,youtube

This reduces 32 idle workers to 9, eliminating ~23 long-pollers and their CPU/RAM/connection overhead.

Backwards compatibility

When POSTIZ_ACTIVE_PROVIDERS is unset (the default), all 32 workers start exactly as before. Existing deployments are completely unaffected — no action required on upgrade.

Changes

  • libraries/nestjs-libraries/src/temporal/temporal.module.ts — adds parseActiveProviders() helper and a second .filter() step in the worker list builder
  • .env.example — documents the new variable with all available provider identifiers

Testing

  • Unset POSTIZ_ACTIVE_PROVIDERS → all 32 workers start (existing behaviour )
  • POSTIZ_ACTIVE_PROVIDERS=twitter,instagram → 3 workers start: main + twitter + instagram
  • POSTIZ_ACTIVE_PROVIDERS=TWITTER, Instagram → case-insensitive + whitespace-trimmed → same 3 workers
  • POSTIZ_ACTIVE_PROVIDERS= (empty string) → treated as unset, all workers start

Closes #1570

@postiz-contribution postiz-contribution Bot added the contribution:approved Approved contributor label Jun 30, 2026
@postiz-contribution

Copy link
Copy Markdown

Contribution-checker quality warning
Heuristic score: 0/100 (low). This is a non-blocking warning surfaced by the project's quality settings.

Heuristics that flagged:

  • Excessive emojis in body: 4 emojis (>2)
  • Excessive inline code references: 17 inline refs (>3)
  • PR doesn't use the repo's PR template: 5 required checkbox items missing (max 1, match ≥80%)
  • Body adds too many extra headers beyond the template: 6 extra headers (>1)
  • Commit message too long: Longest: 1136 chars
  • Excessive added comments: 21 added comment lines (ratio 1.24)
  • No public email

If this is a genuine contribution, please add detail to your PR description and tighten the diff scope before reviewers look at it.

@postiz-agent

postiz-agent Bot commented Jun 30, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Comment thread .env.example Outdated
@onyedikachi-david onyedikachi-david force-pushed the fix/temporal-idle-workers-postiz-active-providers branch from 7620b2a to 3d7ed28 Compare June 30, 2026 01:20
@postiz-contribution

Copy link
Copy Markdown

Contribution-checker quality warning
Heuristic score: 16/100 (low). This is a non-blocking warning surfaced by the project's quality settings.

Heuristics that flagged:

  • Excessive inline code references: 17 inline refs (>3)
  • PR doesn't use the repo's PR template: 5 required checkbox items missing (max 1, match ≥80%)
  • Body adds too many extra headers beyond the template: 6 extra headers (>1)
  • Commit message too long: Longest: 1136 chars
  • No public email

If this is a genuine contribution, please add detail to your PR description and tighten the diff scope before reviewers look at it.

…l workers

On a default Postiz deployment, getTemporalModule starts one Temporal
worker per supported social provider (31 providers + 'main' = 32 workers),
regardless of which integrations are actually configured. Each worker
long-polls Temporal continuously, causing significant idle CPU/RAM usage
even when no posts are scheduled.

Root cause (temporal.module.ts): the worker list was built from the full
socialIntegrationList with no opt-out mechanism.

Fix: introduce an optional POSTIZ_ACTIVE_PROVIDERS env var — a comma-
separated list of provider identifiers. When set, only those providers
(plus the always-required 'main' worker) start Temporal workers.
When unset (the default), all workers start as before — fully
backwards-compatible with existing deployments.

Example for a deployment using 8 providers:

  POSTIZ_ACTIVE_PROVIDERS=twitter,instagram,linkedin,bluesky,telegram,facebook,threads,youtube

This reduces worker count from 32 to 9, eliminating ~23 idle long-pollers
and their associated CPU, RAM, and Postgres connection overhead.

Closes gitroomhq#1570
@onyedikachi-david onyedikachi-david force-pushed the fix/temporal-idle-workers-postiz-active-providers branch from 3d7ed28 to 39ab748 Compare June 30, 2026 01:31
@postiz-contribution

Copy link
Copy Markdown

Contribution-checker quality warning
Heuristic score: 16/100 (low). This is a non-blocking warning surfaced by the project's quality settings.

Heuristics that flagged:

  • Excessive inline code references: 17 inline refs (>3)
  • PR doesn't use the repo's PR template: 5 required checkbox items missing (max 1, match ≥80%)
  • Body adds too many extra headers beyond the template: 6 extra headers (>1)
  • Commit message too long: Longest: 1136 chars
  • No public email

If this is a genuine contribution, please add detail to your PR description and tighten the diff scope before reviewers look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution:approved Approved contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Temporal: 32 auto-started workers (one per provider) cause constant idle CPU/RAM regardless of configured integrations

1 participant