Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A client is supposed to poll the queue for new items (i.e. issue pop requests in a loop), or is there some better event-oriented approach for this (via pg notify ?)


pop() or read() in a loop, yes. can read 1 message or many messages at a time.

what we do at Tembo in our infrastructure is pause for up to a few seconds if a read() returns no messages. when there are messages, then we read() with no pause in between. when the queues are empty it amounts to less than one query per second. there is not much cost to reading frequently if you use a client side connection pool, or a server side pool like pgbouncer.


I've thought about this too. But I can't even tell what would be the good default. At low load events seem nicer, but at high load polling seems necessary?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: