Postgres LISTEN/NOTIFY actually scales
Source Entity
Hacker News

Postgres LISTEN/NOTIFY is often unfairly maligned for scalability issues due to its global lock architecture. New performance optimizations prove it can achieve 60,000 writes per second while maintaining low-latency streaming capabilities.
Rethinking the Scalability of Postgres LISTEN/NOTIFY
For years, the PostgreSQL LISTEN/NOTIFY mechanism has carried a somewhat tarnished reputation in the database engineering community. Driven by widely circulated technical critiques, many developers have avoided using this feature for high-throughput applications, fearing that its underlying architecture would become a bottleneck. However, the recent re-evaluation of this tool suggests that the previous consensus was based on a misunderstanding of its mechanics rather than an inherent failure of the system.
Deconstructing the 'Global Lock' Myth
The primary criticism leveled against LISTEN/NOTIFY involves its use of a global lock, which many argue prevents it from scaling efficiently. While it is true that this lock creates unique, often unintuitive performance characteristics, the assertion that it is fundamentally 'not scalable' is a misnomer. The complexity lies in how the database manages these notifications, but with precise engineering and architectural adjustments, these behaviors can be mitigated to support robust, production-grade workloads.
Achieving High-Performance Throughput
The recent benchmarks demonstrate that with proper optimization, LISTEN/NOTIFY can be effectively utilized for low-latency, durable notifications and pub/sub patterns. By re-engineering the approach to how streams are handled within a PostgreSQL environment, developers have successfully achieved 60,000 writes per second on a single server. This level of performance, coupled with millisecond-scale latency, positions LISTEN/NOTIFY as a viable alternative to external message brokers for certain use cases.
The Architecture of Postgres-Backed Streams
The foundation of this approach relies on a simple design: utilizing a dedicated streams table within the database. By leveraging the database's native ACID compliance, these streams gain the benefit of durability—a feature often lacking in lightweight, volatile message queues. This allows developers to maintain data integrity while simultaneously broadcasting events to subscribers in real-time, effectively blurring the line between a traditional database and a streaming engine.
Future Trends in Database Event-Driven Design
This shift in perspective signals a broader trend toward 'database-as-a-service' patterns, where the database does more than just store data; it acts as the primary event bus for the entire application stack. As developers continue to push the limits of PostgreSQL, we are likely to see more tools that embrace native features rather than adding unnecessary external infrastructure. The ability to handle high-frequency streams directly inside the database reduces architectural complexity and operational overhead.
Conclusion
The rediscovery of LISTEN/NOTIFY as a scalable tool serves as a reminder that performance often depends more on implementation than on the tool itself. By moving beyond the dogma that has historically limited the use of these native features, the engineering community can leverage the full power of PostgreSQL to build faster, simpler, and more reliable event-driven systems.