Grokking Redis
0% completed
4.7 Reliable Job Queues with Lists
The simplest Redis queue uses RPUSH to add a job and BLPOP to take one. It is fast and easy to build, but it can lose jobs without any error. BLPOP removes the job from Redis before the worker has done anything with it, so if the worker crashes, is killed during a deploy, or loses its connection after the reply is sent, the job no longer exists anywhere.
The fix is to make sure a job is always stored somewhere in Redis until its work is finished. The worker moves the job atomically from a pending list to a processing list, and deletes it only when the work succeeds
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%