---
title: "Fan-out from Postgres with Change Data Capture using Debezium and Upstash Redis"
description: "Streaming committed Postgres changes from the write-ahead log via a logical replication slot avoids the dual-write problem, where an application writes to the database and a message broker separately and can leave them inconsistent."
url: "https://swe.quest/articles/fan-out-from-postgres-with-change-data-capture-using-debezium-and-upstash-redis-1afcb52ed56a9566"
canonical: "https://neon.com/blog/fan-out-postgres-changes-using-debezium-and-upstash-redis"
source: "Neon"
published: "2024-02-14"
difficulty: "medium"
kind: "How-to"
reading_minutes: 9
tags: ["event-driven","postgres","messaging","replication"]
---

# Fan-out from Postgres with Change Data Capture using Debezium and Upstash Redis

A post on [Neon](https://swe.quest/sources/neon.md), published 2024-02-14, 9 min read, How-to. Original: [https://neon.com/blog/fan-out-postgres-changes-using-debezium-and-upstash-redis](https://neon.com/blog/fan-out-postgres-changes-using-debezium-and-upstash-redis)

## Summary

Streaming committed Postgres changes from the write-ahead log via a logical replication slot avoids the dual-write problem, where an application writes to the database and a message broker separately and can leave them inconsistent. LISTEN/NOTIFY doesn't fix this because it is only at-most-once. The guide configures Debezium Server to read Neon's WAL using pgoutput, with an initial snapshot and file-based offset tracking, and to sink change events into an Upstash Redis stream. A Node.js consumer then uses XREADGROUP consumer groups and XACK to get at-least-once fan-out that can resume after restarts.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Event-driven architecture](https://swe.quest/tags/event-driven.md) (Backend & APIs)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Queues & messaging](https://swe.quest/tags/messaging.md) (Backend & APIs)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)

## Prerequisites

- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- Redis streams ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))
- Docker ([easy posts on Containers](https://swe.quest/tags/containers.md?difficulty=easy))

## Keywords

Debezium, Neon, Upstash Redis, Redis Streams, Postgres logical replication, pgoutput, Change Data Capture

## Related posts

- [Event-driven architectures using Neon and Sequin](https://swe.quest/articles/event-driven-architectures-using-neon-and-sequin-8e1877ce94623987.md): Neon · 2024-10-22 · Medium · 5 min read · Event-driven architecture, PostgreSQL, Replication
  Sequin offers a lighter alternative to Debezium plus Kafka for change data capture on Neon Postgres, using a logical replication slot to build a strictly ordered "Sequence" of table rows that consumers can read, rewind and replay without copying data into a separate system.
- [Change Data Capture with Serverless Postgres](https://swe.quest/articles/change-data-capture-with-serverless-postgres-4d667a8d26488042.md): Neon · 2023-12-21 · Medium · 7 min read · PostgreSQL, Replication, Event-driven architecture, Serverless
  Neon has released Postgres logical replication in beta, letting Neon databases act as publishers that stream an initial snapshot plus row-level changes to external stores for change data capture and real-time analytics.
- [Contributing to Debezium: Fixing Logical Replication at Scale](https://swe.quest/articles/contributing-to-debezium-fixing-logical-replication-at-scale-9a91b621ec2af98e.md): Zalando Engineering · 2025-12-18 · Hard · 9 min read · PostgreSQL, Event-driven architecture, Replication, Open source, Data pipelines
  Zalando contributed two configuration options to Debezium's PostgreSQL connector, released in 3.4.0.Final.
- [Change Data Capture (CDC) with PostgreSQL and ClickHouse - Part 1](https://swe.quest/articles/change-data-capture-cdc-with-postgresql-and-clickhouse-part-1-10e3d601e2748dab.md): ClickHouse · 2023-06-15 · Medium · 23 min read · Event-driven architecture, PostgreSQL, Analytics & OLAP, Replication, Queues & messaging
  Postgres-to-ClickHouse CDC can be built by streaming row changes from Postgres logical decoding (pgoutput plugin, replication slots, LSN ordering) through Debezium and Kafka, then applying them in ClickHouse with the ReplacingMergeTree engine.
- [Stream data from Neon to external data sources via logical replication](https://swe.quest/articles/stream-data-from-neon-to-external-data-sources-via-logical-replication-ba0a37ed2d47496f.md): Neon · 2024-08-09 · Medium · 7 min read · PostgreSQL, Replication, Event-driven architecture, Data pipelines
  Neon now supports outbound Postgres logical replication in beta, letting a Neon database publish WAL-decoded inserts, updates and deletes to warehouses, Kafka, CDC tools and other Postgres databases; inbound replication is coming later.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
