---
title: "Elixir clustering using Postgres"
description: "Elixir nodes can discover each other for distributed Erlang clustering through Postgres LISTEN/NOTIFY, which avoids a cloud-specific discovery service."
url: "https://swe.quest/articles/elixir-clustering-using-postgres-4f3e50a2eab83f34"
canonical: "https://supabase.com/blog/elixir-clustering-using-postgres"
source: "Supabase"
published: "2024-01-09"
difficulty: "medium"
kind: "How-to"
reading_minutes: 4
tags: ["elixir-erlang","postgres","distributed-systems"]
---

# Elixir clustering using Postgres

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2024-01-09, 4 min read, How-to. Original: [https://supabase.com/blog/elixir-clustering-using-postgres](https://supabase.com/blog/elixir-clustering-using-postgres)

## Summary

Elixir nodes can discover each other for distributed Erlang clustering through Postgres LISTEN/NOTIFY, which avoids a cloud-specific discovery service. The libcluster Postgres strategy has each node NOTIFY a configured channel with its node() name. Each node listens for notifications via Postgrex.Notifications and connects to any node it hears about. A periodic heartbeat re-broadcasts the node name so libcluster can heal the cluster. Supabase uses this in Logflare, Supavisor and Realtime and has open-sourced it as libcluster\_postgres.

Written by swe.quest, not by the author.

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

## Topics

- [Elixir & Erlang](https://swe.quest/tags/elixir-erlang.md) (Languages)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Distributed systems](https://swe.quest/tags/distributed-systems.md) (Distributed systems)

## Prerequisites

- Elixir GenServers ([easy posts on Elixir & Erlang](https://swe.quest/tags/elixir-erlang.md?difficulty=easy))
- distributed Erlang nodes ([easy posts on Elixir & Erlang](https://swe.quest/tags/elixir-erlang.md?difficulty=easy))
- Postgres basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))

## Keywords

libcluster, libcluster\_postgres, Postgrex, LISTEN/NOTIFY, Supabase, BEAM

## Related posts

- [Supavisor 1.0: a scalable connection pooler for Postgres](https://swe.quest/articles/supavisor-1-0-a-scalable-connection-pooler-for-postgres-561015cc29e3cac0.md): Supabase · 2023-12-13 · Medium · 3 min read · PostgreSQL, Elixir & Erlang, Load balancing, Replication
  Supavisor 1.0, Supabase's Elixir-based Postgres connection pooler, is production-ready and adds query load balancing, named prepared statement support in transaction mode, and query cancelation.
- [Realtime: Multiplayer Edition](https://swe.quest/articles/realtime-multiplayer-edition-cca475e0a0be51ab.md): Supabase · 2022-08-18 · Medium · 8 min read · Real-time systems, Elixir & Erlang, PostgreSQL, JavaScript
  Supabase Realtime's Broadcast and Presence features are now generally available, with every feature organized around Channels that also carry Postgres change events.
- [How We Export Postgres Logs to Third-Party Services](https://swe.quest/articles/how-we-export-postgres-logs-to-third-party-services-bed5372bbc749f83.md): Neon · 2025-06-24 · Medium · 4 min read · Observability, PostgreSQL, Kubernetes
  Neon exports customer Postgres logs by having Postgres write to rsyslogd alongside stderr, with rsyslogd pushing RFC 5424 syslog over TCP to an OpenTelemetry Collector that enriches and forwards them to Datadog or any OTLP-compatible platform.
- [Supavisor: Scaling Postgres to 1 Million Connections](https://swe.quest/articles/supavisor-scaling-postgres-to-1-million-connections-8585e4b9712f0334.md): Supabase · 2023-08-11 · Medium · 7 min read · PostgreSQL, Elixir & Erlang, Scaling, Multi-tenancy, Performance engineering
  Supavisor is a multi-tenant Postgres connection pooler written in Elixir that Supabase built to replace single-threaded PgBouncer.
- [Postgres Meets Analytics: CDC From Neon to ClickHouse Via PeerDB](https://swe.quest/articles/postgres-meets-analytics-cdc-from-neon-to-clickhouse-via-peerdb-669fe8e963909dd5.md): Neon · 2024-10-02 · Medium · 5 min read · PostgreSQL, Event-driven architecture, Analytics & OLAP, Replication, Data pipelines
  Neon serverless Postgres can serve as the transactional system of record while ClickHouse handles real-time analytics, with PeerDB streaming changes between them via Postgres logical replication.

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)
