Skip to content
Skills Library
DevOps & cloud · Building & coding

scaling-workflows

/scaling-workflows

Scale Flowcraft workflows from in-memory to distributed execution using adapters (BullMQ, SQS, RabbitMQ, GCP, Azure, Kafka, Cloudflare). Covers durable primitives, middleware, and observability. Use when deploying workflows to production, configuring distributed execution, setting up message queues, adding middleware, or enabling observability.

Repository
flowcraft ↗
Licence
MIT
Last repository change
02.07.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
7
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 02.07.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Scale Flowcraft workflows from in-memory to distributed execution using adapters (BullMQ, SQS, RabbitMQ, GCP, Azure, Kafka, Cloudflare). Covers durable primitives, middleware, and observability. Use when deploying workflows to production, configuring distributed execution, setting up message queues, adding middleware, or enabling observability.

Original author description

Scale Flowcraft workflows from in-memory to distributed execution using adapters (BullMQ, SQS, RabbitMQ, GCP, Azure, Kafka, Cloudflare). Covers durable primitives, middleware, and observability. Use when deploying workflows to production, configuring distributed execution, setting up message queues, adding middleware, or enabling observability.

How it works

  1. Architecture
  2. Distributed adapters
  3. Durable primitives
  4. Middleware pipeline
  5. Observability
  6. Coordination patterns
  7. Advanced topics
Original SKILL.md headings · 157 lines, 454 words
SKILL.md preview
---
name: scaling-workflows
description: Scale Flowcraft workflows from in-memory to distributed execution using adapters (BullMQ, SQS, RabbitMQ, GCP, Azure, Kafka, Cloudflare). Covers durable primitives, middleware, and observability. Use when deploying workflows to production, configuring distributed execution, setting up message queues, adding middleware, or enabling observability.
---

# Scaling Workflows

Flowcraft workflows scale from in-memory to distributed systems without changing core business logic. Adapters abstract the queue technology.

## Architecture

```
In-Memory (development)          Distributed (production)
  FlowRuntime                      FlowRuntime + Adapter
  Direct execute                   Queue-based execute
  Single process                   Multi-worker/process
```

## Distributed adapters

All adapters extend `BaseDistributedAdapter` and implement:

- `createContext()` — initialize coordination state
- `processJobs()` — handle incoming node executions
- `enqueueJob()` — dispatch nodes to workers
- `publishFinalResult()` — emit workflow completion

### Available adapters

| Adapter    | Queue Technology   | See                                          |
| ---------- | ------------------ | -------------------------------------------- |
| BullMQ     | Redis              | [adapters/bullmq.md](adapters/bullmq.md)     |
| SQS        | AWS SQS            | [adapters/sqs.md](adapters/sqs.md)           |
| RabbitMQ   | RabbitMQ/AMQP      | [adapters/rabbitmq.md](adapters/rabbitmq.md) |
| GCP        | Google Cloud Tasks | [adapters/cloud.md](adapters/cloud.md)       |
| Azure      | Azure Service Bus  | [adapters/cloud.md](adapters/cloud.md)       |
| Kafka      | Apache Kafka       | [adapters/cloud.md](adapters/cloud.md)       |
| Cloudflare | Cloudflare Queues  | [adapters/cloud.md](adapters/cloud.md)       |
| Vercel     | Vercel Queues      | [adapters/cloud.md](adapters/cloud.md)       |

### Adapter setup pattern

```typescript
import { FlowRuntime } from 'flowcraft'
import { BullMQAdapter } from '@flowcraft/adapter-bullmq'

const adapter = new BullMQAdapter({
	connection: { host: 'localhost', port: 6379 },
	prefix: 'flowcraft',
})

const runtime = new FlowRuntime()
const result = await adapter.run(blueprint, initialState, {
	functionRegistry,
	maxConcurrency: 10,
})
```

## Durable primitives

### SleepNode — durable timers

```typescript
.flow.sleep('delay', { duration: 5000 })
```

Use `runtime.startScheduler()` to auto-resume.

### WaitNode — human-in-the-loop

```typescript
.flow.wait('approval')
```

Resume with: `await runtime.resume(blueprint, serializedContext, resumeData)`

### WebhookNode — external triggers

```typescript
.flow.node('webhook', {
  uses: 'webhook',
  params: { path: '/hooks/payment', secret: 'wh_secret' },
})
```

### SubflowNode — nested workflows

```typescript
.flow.node('sub', {
  uses: 'subflow',
  params: { blueprintId: 'child-workflow' },
  inputs: { data: 'parent-node' },
})
```

## Middleware pipeline

```typescript
const middleware: Middleware[] = [
	{
		async beforeNode(ctx) {
			console.log(`Starting ${ctx.nodeId}`)
		},
		async afterNode(ctx, result) {
			console.log(`Finished ${ctx.nodeId}`)
		},
		async aroundNode(ctx, next) {
			const start = Date.now()
			const result = await next()
			console.log(`${ctx.nodeId} took ${Date.now() - start}ms`)
			return result
		},
	},
]

const runtime = new FlowRuntime({ middleware })
```

**Lifecycle order:**

1. `beforeNode` hooks (in order)
2. `aroundNode` hooks (wrap in reverse order)
3. Node execution (prep → exec → post)
4. `afterNode` hooks (in order)

## Observability

### OpenTelemetry

```typescript
import { OpenTelemetryMiddleware } from '@flowcraft/middleware-opentelemetry'

const runtime = new FlowRuntime({
	middleware: [OpenTelemetryMiddleware()],
})
```

### Event bus

Key event types: `workflow:start/finish/stall/pause/resume`, `node:start/finish/error/retry`, `context:change`, `batch:start/finish`.

## Coordination patterns

### Delta-based persistence

`TrackedAsyncContext` records only mutations, reducing payload by 80-95%.

### Poison pill pattern

Failed nodes write cancellation pills to prevent stalling successors.

### Fan-in joins

`joinStrategy: 'all'` (wait for all) or `'any'` (first-come-wins with locking).

## Advanced topics

- **Adapter configuration details**: See adapter reference files linked above
- **Durable primitive patterns**: See [primitives.md](primitives.md)
- **Custom middleware**: See [middleware.md](middleware.md)
Files in this package (7)
  • SKILL.md 4 KB
  • middleware.md 5 KB
  • primitives.md 4 KB
  • adapters/bullmq.md 3 KB
  • adapters/cloud.md 1 KB
  • adapters/rabbitmq.md 1 KB
  • adapters/sqs.md 1 KB

Versions

The database has no other skills named scaling-workflows.

Database snapshot: 13.11.2026 · package version b7510c724b24 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 4 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100sqs
    Amazon SQS managed message queue service. Covers standard and FIFO queues, dead-letter queues, and integration patterns. Use for AWS-native serverless and microservices architectures. USE WHEN: user mentions "sqs", "aws queues", "fifo queue", "lambda trigger", "sns to sqs", asks…
  • 100enable-dsm
    Enable Data Streams Monitoring (DSM) on services already instrumented with APM, for end-to-end latency, throughput, and consumer lag across Kafka, RabbitMQ, SQS, SNS, Kinesis, Pub/Sub, IBM MQ, Azure Service Bus, and BullMQ pipelines. Use when the user asks for data streams,…
  • 100argo-events-and-event-driven-automation
    Configures Argo Events `EventSource`, `Sensor`, and `EventBus` CRDs to trigger Argo Workflows, Kubernetes resource changes, or other actions from external events — webhooks, message queues (Kafka/NATS/SQS/ RabbitMQ), and cron schedules. Use when the user asks to "trigger an Argo…
  • 80role-backend:message-queues
    Implements message queue systems using RabbitMQ, Apache Kafka, Redis Streams, AWS SQS/SNS, and Google Pub/Sub. Covers topics, exchanges, dead letter queues, idempotency, ordering guarantees, consumer groups, backpressure handling, and message serialization. Use when setting up…
  • 100event-driven-architecture
    Kafka, RabbitMQ, SQS/SNS, event sourcing, CQRS, saga patterns, dead letter queues, and idempotency. Use when designing asynchronous systems, implementing message-driven workflows, or building event streaming pipelines.
  • 95cloudflare-workflows
    Cloudflare Workflows for durable long-running execution. Use for multi-step workflows, retries, state persistence, or encountering NonRetryableError, execution failed errors.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.