D2 Technology · first-party infrastructure proof

Hạ tầng n8n production self-hosted trên Docker Swarm.

Đây là kiến trúc production đứng sau n8n runtime của chính D2 Group. Hệ thống tách ingress, request handling, queue execution, Code-node runner và durable state — đồng thời đặt guarded deployment, encrypted recovery và operational change control quanh chính các workflow.

D2 Group tự thiết kế và vận hành · single-node Swarm có chủ đích · không phải uptime claim

n8n.d2group.co

Docker Swarm production topology

Queue modeSingle-node boundary

Upstream TLS proxy

Sets origin access token

Caddy origin

Routing · origin guard · headers

n8n main

Editor · REST · OAuth · test endpoints

Webhook pool ×2

Webhook · form · MCP production

Redis / Bull

Shared execution queue

Worker 1

Queue consumer · concurrency 8 default

Worker 2

Queue consumer · concurrency 8 default

Runner · main

Isolated task runners · Code execution

Runner · worker 1

One-to-one broker pairing

Runner · worker 2

One-to-one broker pairing

PostgreSQL 16

Workflow state · execution data · binary data · durable database state

Docker Secrets

Encryption · DB · Redis · runner auth

Queue mode separates responsibilities and concurrency. The Docker host, PostgreSQL, Redis and Caddy are not HA.

1

main / editor

Control plane · REST · OAuth

2

webhook processors

Production webhook · form · MCP

2

worker services

Queue consumers · concurrency 8 default

3

external runner pairs

Main + one-to-one worker runners

Production engineering

Đây không phải một container demo.

Hệ thống được thiết kế từ những failure mode xuất hiện khi automation trở thành hạ tầng vận hành: concurrent execution, Code-node isolation, secret handling, database migration, stale backup, direct-origin access và workflow drift.

failure mode

Code task blocks

External runners + explicit task timeout

failure mode

Worker/process failure

Queue execution + health-gated services

failure mode

Secret exposure

Docker Secrets + runtime bridge

failure mode

Unsafe upgrade

Immutable images + recovery point + guarded migration

failure mode

Backup exists but fails

Verification + disposable restore drill

failure mode

Live workflow diverges

Private Git export + drift detection

Runtime topology

Một physical host. Nhiều production responsibility được tách rõ.

Docker Swarm orchestration các service trên một manager node. Queue mode tách request handling khỏi execution, còn dedicated external task runner tách JavaScript/Python Code-node work khỏi các n8n process điều phối workflow.

n8n.d2group.co

Docker Swarm production topology

Queue modeSingle-node boundary

Upstream TLS proxy

Sets origin access token

Caddy origin

Routing · origin guard · headers

n8n main

Editor · REST · OAuth · test endpoints

Webhook pool ×2

Webhook · form · MCP production

Redis / Bull

Shared execution queue

Worker 1

Queue consumer · concurrency 8 default

Worker 2

Queue consumer · concurrency 8 default

Runner · main

Isolated task runners · Code execution

Runner · worker 1

One-to-one broker pairing

Runner · worker 2

One-to-one broker pairing

PostgreSQL 16

Workflow state · execution data · binary data · durable database state

Docker Secrets

Encryption · DB · Redis · runner auth

Queue mode separates responsibilities and concurrency. The Docker host, PostgreSQL, Redis and Caddy are not HA.

Network model

edge

Caddy ↔ main / webhook processors

backend

PostgreSQL · Redis · n8n internals · runner brokers

egress

Outbound access for workers / runners

Queue semantics

One shared Bull queue.

Worker 1 and Worker 2 are named services for stable one-to-one runner pairing. They are not separate workload queues.

Execution path

Production request không thực thi bên trong webhook process.

Webhook, form và MCP production đi qua guarded origin, được webhook pool tiếp nhận, đưa vào Redis/Bull queue rồi worker consume. Workflow state cùng binary/execution data được giữ durable trong PostgreSQL.

Caddy

guard + route

Webhook pool

receive request

Redis / Bull

queue job

Worker

consume execution

Task runner

Code isolation

PostgreSQL

durable state

Test traffic

webhook-test · form-test · mcp-test → main/editor

Production traffic

webhook · form · MCP → horizontally-scaled webhook pool

Execution

workers consume the shared queue; Code runs in external runners

Production invariants

Reliability bắt đầu trước node đầu tiên của workflow.

D2 xem runtime identity, health, secret, recovery và deployment precondition là operating rule nằm trong code, không chỉ là khuyến nghị trong tài liệu.

Immutable runtime identity

n8n, runner và proxy image được pin bằng immutable identity để normal deploy không âm thầm đổi runtime version.

Health gates

Deployment chờ real service health, bao gồm n8n readiness cùng runner launcher/broker health — không chỉ container state.

Docker Secrets bridge

Sensitive value nằm ngoài Git và Swarm environment specification, sau đó được bridge vào supported n8n runtime variable khi start.

Durable queue-mode data

Execution data và binary payload dùng PostgreSQL database mode; Redis vận chuyển job nhưng không phải authoritative execution store.

Guarded deploy path

Production changes pass through explicit gates.

backup-first

01

Validate config

02

Create recovery point

03

Verify backup

04

Pull exact images

05

Deploy Swarm services

06

Wait for health gates

Security boundary

Origin, secret và internal service đều có boundary rõ ràng.

Public edge được tách khỏi backend service. PostgreSQL, Redis và runner broker không publish host port; sensitive value nằm trong Docker Secrets; Caddy yêu cầu upstream origin token trước khi forward real traffic.

Origin guard

Caddy yêu cầu secret upstream header cho real traffic và strip token trước khi request tới n8n.

Private backend

PostgreSQL và Redis nằm trên internal Docker network, không publish host port.

Private runner brokers

Task-runner broker traffic nằm trong Docker network; runner/broker host port không được expose.

Metrics boundary

Metrics route bị block tại application origin thay vì expose qua public proxy path.

Origin request

Direct-origin traffic must prove it came through the upstream proxy.

Upstream proxy

Overwrite / set token

Caddy

Validate token

n8n

Token stripped upstream

Backup & disaster recovery

Backup chỉ có giá trị khi restore path thực sự chạy được.

Production change tạo verified recovery point. Offsite material được encrypt trước upload, còn disposable PostgreSQL restore drill kiểm tra recovery data có thực sự restore được trước khi incident xảy ra.

Verified recovery point

Normal production change tạo và verify recovery point trước khi deployment tiếp tục.

Encrypted offsite backup

Recovery material được encrypt trước offsite upload và plaintext staging được cleanup sau cả success lẫn failure.

Disposable restore drill

Real PostgreSQL restore path kiểm tra backup material có thực sự rebuild database state được hay không.

Guarded production restore

Full-host recovery từ chối conflicting stack state, missing input, repository mismatch hoặc mutable runtime image.

Recovery logic

Image rollback alone is not a safe database rollback strategy.

n8n upgrades can include database migrations. Recovery therefore records the repository/runtime state and restores data intentionally instead of assuming an older image can reverse schema changes.

01

Backup

02

Encrypt

03

Restore drill

04

Post-flight checks

Operating control

Vận hành cả platform lẫn workflow definition.

Monitoring kiểm tra service readiness, queue/database signal, failed execution, disk pressure và backup age. Production workflow definition có thể export vào private Git và so với live UI để phát hiện drift.

Platform health

Service health, n8n readiness, Redis queue/memory, PostgreSQL connection, failure và disk pressure được monitor.

Backup age

Stale recovery point được xem là operational exception thay vì mặc định scheduled backup đồng nghĩa recoverable backup.

Workflow drift

Production workflow có thể export vào private Git và so với live definition được thay đổi qua UI.

CI invariants

Repository check bao phủ production invariant, pinned image, secret bridge, runner tooling và live broker/runner smoke topology.

Every 5 min

Health / capacity monitor

Daily · 03:15

Encrypted offsite backup when configured

Daily · 04:00

Workflow drift check

Architecture boundary

Production-ready không có nghĩa gọi một host là high availability.

PostgreSQL, Redis, Caddy và Docker host vẫn là single point of failure. Queue mode cải thiện concurrency và responsibility separation; resilience đến từ recovery control chứ không phải gắn nhãn HA cho một máy.

What the architecture does provide

Separated request handling and execution
External isolation for Code-node tasks
Durable database-backed queue-mode data
Guarded deploy and tested recovery controls
Monitoring and workflow change visibility

Does not claim

Multi-host high availability
Zero-downtime guarantee
Guaranteed draining of in-flight Code tasks during restart
Unlimited database-mode binary payload size
That CI proves the live production host is healthy

What this proves

D2 có thể engineer runtime đứng sau automation — không chỉ workflow nằm trên nó.

First-party stack này chứng minh infrastructure discipline D2 áp dụng khi automation trở thành business-critical: architecture, deployment safety, failure handling, observability, recovery và change control.

Architecture

Topology · network · execution model

Reliability

Health gates · timeouts · durable state

Recovery

Verified backup · restore drill · DR

Change control

Pinned runtime · CI · workflow drift

n8n Automation & API Integration

Cần n8n workflow engineering và API integration?

D2 thiết kế workflow trên runtime do D2 hoặc khách hàng quản lý, với scope xoay quanh business event, API, failure mode, retry, idempotency và operating ownership.