long-poll worker pattern
Worker keeps a connection open to the queue and gets notified the moment work arrives, instead of polling on an interval. Lower latency than tick-polling without sustained connections like SSE.
Worker keeps a connection open to the queue and gets notified the moment work arrives, instead of polling on an interval. Lower latency than tick-polling without sustained connections like SSE.
symptoms
- job latency dominated by poll interval
- worker idle but still using CPU on poll loops
causes
- short fixed-interval polling against a queue
fixes
- SQS ReceiveMessage with WaitTimeSeconds
- BLPOP / BRPOP for Redis
- Postgres LISTEN/NOTIFY
you might say
- the worker is long-polling
- blocking receive