Menu

Post image 1
Post image 2
Post image 3
Post image 4
Post image 5
1 / 5
0

Postgres LISTEN/NOTIFY Actually Scales

Hacker News·2 months ago
#Gc5q3tUp
Reading 0:00
15s threshold

Postgres LISTEN/NOTIFY has a bad reputation thanks in part to a popular blog post asserting it does not scale . If that were true, it would be a shame, because LISTEN/NOTIFY is a powerful tool, allowing you to use your Postgres database for low-latency durable notifications, streams, and pub/sub. The accusations aren’t wrong: NOTIFY has unintuitive and undocumented performance characteristics arising from its use of a global lock. But “unintuitive behavior” is not the same as “not scalable.” In this blog post, we’ll show how we optimized LISTEN/NOTIFY-backed streams at scale, achieving 60K writes per second on a single Postgres server with millisecond-scale latency. Low-Latency Streaming with LISTEN/NOTIFY The basic design of Postgres-backed streams is simple: create a streams table where each stream chunk (for example, an LLM response token) is a new row, then write to streams by inserting into the table. ‍ The tricky part is reading from the stream because you don't know when the next chunk will arrive.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More