Hacker News new | ask | show | jobs
by qooleot 3538 days ago
We don't use postgres pub/sub for exactly "realtime", but do make use of it in single-page apps that use websockets. A couple notes:

-- LISTEN/NOTIFY has a payload size hardcoded maximum. For big documents, we have to send a record ID then fetch the document upon receiving a message. In practice, it adds 5ms of overhead.

-- One of the best features is that you can combine this with pg_try_advisory_lock to create job queues that use the core locking features of postgres, which are pretty darn reliable and well defined. We use nodejs, and if the server processing a job dies, the lock is released automatically and another nodejs process can pick it up.

1 comments

Note that as of Postgres 9.5, you can use SKIP LOCKED for roughly the same usecase.