Choose and deploy message broker #12

Closed
opened 2026-03-21 00:12:52 +01:00 by martin · 1 comment
Owner

Evaluate and deploy NATS JetStream (preferred) vs Redis Streams.

  • Must be native Kubernetes
  • Support at-least-once delivery
  • Define final message schema (see README for draft)
Evaluate and deploy **NATS JetStream** (preferred) vs Redis Streams. - Must be native Kubernetes - Support at-least-once delivery - Define final message schema (see README for draft)
martin added this to the Phase 3 — Message Broker + Arbiter milestone 2026-03-21 00:12:52 +01:00
martin added the infrabroker labels 2026-03-21 00:12:52 +01:00
martin added this to the Road to Pompeo project 2026-03-21 11:27:36 +01:00
martin moved this to To Do in Road to Pompeo on 2026-03-21 11:28:15 +01:00
martin moved this to In Progress in Road to Pompeo on 2026-03-21 11:52:57 +01:00
martin started working 2026-03-21 12:01:03 +01:00
Author
Owner

Il broker è ancora necessario?

Quando hai progettato l'architettura, il broker serviva per disaccoppiare gli agenti dall'Arbiter. Ma oggi hai già agent_messages su PostgreSQL che fa
esattamente quella cosa — e l'hai appena costruita.

Quello che hai adesso:

Agente n8n → INSERT agent_messages (arbiter_decision = NULL)
Arbiter → SELECT ... WHERE arbiter_decision IS NULL (cron)
→ UPDATE arbiter_decision = 'notify'/'defer'/'discard'

Questo è un message broker — persistente, queryabile, con audit log. Il 90% del valore di NATS/Redis Streams lo hai già gratis con Postgres.


L'unico caso che Postgres non copre

Il bypass high-priority: quando un agente rileva un alert critico (es. disco pieno, bolletta scaduta), deve svegliare l'Arbiter immediatamente senza aspettare il
cron.

Soluzione banale: n8n webhook diretto. L'agente chiama il webhook dell'Arbiter con priority: high. Zero infrastruttura aggiuntiva.


Se vuoi comunque un broker "vero"

┌─────────────────────────┬─────────────────────────┬────────────────────────────────┐
│ │ Redis Streams │ NATS JetStream │
├─────────────────────────┼─────────────────────────┼────────────────────────────────┤
│ Già in cluster │ sì (Redis HA attivo) │ da deployare │
├─────────────────────────┼─────────────────────────┼────────────────────────────────┤
│ n8n supporto nativo │ nodo Redis nativo │ ⚠️ solo via HTTP/custom │
├─────────────────────────┼─────────────────────────┼────────────────────────────────┤
│ Overhead operativo │ zero (già gestito) │ nuovo componente da monitorare │
├─────────────────────────┼─────────────────────────┼────────────────────────────────┤
│ Replay messaggi │ sì │ sì (più potente) │
├─────────────────────────┼─────────────────────────┼────────────────────────────────┤
│ Adatto al volume │ (pochi msg/ora) │ ma sovradimensionato │
├─────────────────────────┼─────────────────────────┼────────────────────────────────┤
│ Caso d'uso ALPHA │ sufficiente │ overkill │
└─────────────────────────┴─────────────────────────┴────────────────────────────────┘


La mia raccomandazione

Non deployare né NATS né Redis Streams adesso. Usa:

  1. agent_messages su Postgres → flow normale (Arbiter a cron)
  2. Webhook n8n diretto → bypass high-priority

Se in futuro il volume cresce o ti servono pattern più complessi (fan-out multi-subscriber, replay, retention policy), aggiungi Redis Streams (già lì, zero
setup).

NATS JetStream lo valuterei solo se ALPHA_PROJECT diventasse multi-household o dovesse scalare orizzontalmente — scenari lontani dal tuo homelab.

Il broker è ancora necessario? Quando hai progettato l'architettura, il broker serviva per disaccoppiare gli agenti dall'Arbiter. Ma oggi hai già agent_messages su PostgreSQL che fa esattamente quella cosa — e l'hai appena costruita. Quello che hai adesso: Agente n8n → INSERT agent_messages (arbiter_decision = NULL) Arbiter → SELECT ... WHERE arbiter_decision IS NULL (cron) → UPDATE arbiter_decision = 'notify'/'defer'/'discard' Questo è un message broker — persistente, queryabile, con audit log. Il 90% del valore di NATS/Redis Streams lo hai già gratis con Postgres. ---------------------------------------------------------------------------------------------------------------------------------------------------------------- L'unico caso che Postgres non copre Il bypass high-priority: quando un agente rileva un alert critico (es. disco pieno, bolletta scaduta), deve svegliare l'Arbiter immediatamente senza aspettare il cron. Soluzione banale: n8n webhook diretto. L'agente chiama il webhook dell'Arbiter con priority: high. Zero infrastruttura aggiuntiva. ---------------------------------------------------------------------------------------------------------------------------------------------------------------- Se vuoi comunque un broker "vero" ┌─────────────────────────┬─────────────────────────┬────────────────────────────────┐ │ │ Redis Streams │ NATS JetStream │ ├─────────────────────────┼─────────────────────────┼────────────────────────────────┤ │ Già in cluster │ ✅ sì (Redis HA attivo) │ ❌ da deployare │ ├─────────────────────────┼─────────────────────────┼────────────────────────────────┤ │ n8n supporto nativo │ ✅ nodo Redis nativo │ ⚠️ solo via HTTP/custom │ ├─────────────────────────┼─────────────────────────┼────────────────────────────────┤ │ Overhead operativo │ zero (già gestito) │ nuovo componente da monitorare │ ├─────────────────────────┼─────────────────────────┼────────────────────────────────┤ │ Replay messaggi │ ✅ sì │ ✅ sì (più potente) │ ├─────────────────────────┼─────────────────────────┼────────────────────────────────┤ │ Adatto al volume │ ✅ (pochi msg/ora) │ ✅ ma sovradimensionato │ ├─────────────────────────┼─────────────────────────┼────────────────────────────────┤ │ Caso d'uso ALPHA │ sufficiente │ overkill │ └─────────────────────────┴─────────────────────────┴────────────────────────────────┘ ---------------------------------------------------------------------------------------------------------------------------------------------------------------- La mia raccomandazione Non deployare né NATS né Redis Streams adesso. Usa: 1. agent_messages su Postgres → flow normale (Arbiter a cron) 2. Webhook n8n diretto → bypass high-priority Se in futuro il volume cresce o ti servono pattern più complessi (fan-out multi-subscriber, replay, retention policy), aggiungi Redis Streams (già lì, zero setup). NATS JetStream lo valuterei solo se ALPHA_PROJECT diventasse multi-household o dovesse scalare orizzontalmente — scenari lontani dal tuo homelab.
martin added reference main 2026-03-21 12:03:18 +01:00
martin worked for 2 minutes 2026-03-21 12:03:23 +01:00
martin moved this to Done in Road to Pompeo on 2026-03-21 12:03:33 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Total Time Spent: 2 minutes
martin
2 minutes
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: martin/Alpha#12