Scrivio Interview library
ConceptFoundations7 min read · updated 13 November 2026

A Redis list can act as a simple work queue: producers push jobs and workers pop them. The simplest version loses jobs when a worker crashes in the middle of one.

Explain why LPUSH with BRPOP is not reliable and how the BLMOVE pattern with a processing list fixes it. What still needs handling?

LPUSH with BRPOP is unreliable because BRPOP deletes the job from Redis the moment it hands it to a worker, so a crash before the work finishes loses the job for good. BLMOVE moves the job atomically into a per-worker processing list instead, and the worker removes it with LREM only after finishing, so a reaper can return the jobs of dead workers to the queue. That gives at-least-once delivery, which still leaves duplicates, retries, poison jobs and delays for us to handle.

Why this question is asked

Plenty of teams start a job queue with two Redis commands because it takes ten minutes to build and it works on the first day. The trouble shows up later, during a deployment or an out-of-memory kill, when a handful of jobs silently never run. Interviewers ask this question to see whether we understand where a job lives at every moment, because that is what decides whether a crash loses it. In this answer, we will recap how a list works as a queue, see exactly where the simple version loses a job, build the processing-list pattern with BLMOVE, add the reaper that recovers jobs from dead workers, and then go through what the pattern still leaves us to handle.

1A Quick Recap of Lists as Queues

A Redis list is an ordered sequence of strings. LPUSH adds an element at the left end, and RPOP removes one from the right end, so pushing on the left and popping on the right gives first-in, first-out order: the oldest job comes out first.

BRPOP is the blocking form of RPOP. If the list is empty, the worker's connection waits on the server, up to a timeout we choose, until a producer pushes something. This is why the pattern is popular: workers do not poll in a loop, and a new job reaches an idle worker within a millisecond or two.

Java
# producer
LPUSH jobs '{"id":"job-981","type":"resize","file":"a.png"}' # (integer) 1
# worker
BRPOP jobs 5
# 1) "jobs"
# 2) "{\"id\":\"job-981\",...}"
LLEN jobs # (integer) 0

Notice the last line. As soon as BRPOP returns, the list is empty. Redis has no record that job-981 exists anywhere any more; it lives only in the memory of the worker process.

2Where the Simple Version Loses a Job

Picture the worker resizing the image. It has popped the job and is halfway through when Kubernetes kills the pod for using too much memory, or a deployment replaces it, or the machine reboots. The job was in the worker's memory, and that memory is gone. Nothing in Redis says the job was started, so nothing will ever retry it.

The reason is that BRPOP mixes two separate events into one: delivering the job to a worker and declaring the job done. A reliable queue needs those two events to be separate, with the job still recorded somewhere between them. That is the whole idea behind the next pattern.

3Moving the Job Into a Processing List With BLMOVE

BLMOVE source destination RIGHT LEFT timeout pops an element from one list and pushes it onto another in a single atomic step, blocking if the source is empty. It arrived in Redis 6.2 and replaces the older BRPOPLPUSH, which did the same thing with fixed directions. Atomic here means there is no moment at which the job is in neither list: either it is still in jobs, or it is already in the processing list.

Each worker gets its own processing list named after itself. When the work is finished, the worker removes that exact job from its processing list with LREM. If the worker dies first, the job is still sitting in processing:worker-1, visible to anyone who looks.

Java
# worker-1 takes a job: right end of jobs -> left end of its processing list
BLMOVE jobs processing:worker-1 RIGHT LEFT 5
# "{\"id\":\"job-981\",...}"
LRANGE processing:worker-1 0 -1 # 1) "{\"id\":\"job-981\",...}" still recorded
# ... the work runs ...
# done: remove exactly one copy of this job
LREM processing:worker-1 1 '{"id":"job-981","type":"resize","file":"a.png"}' # (integer) 1
Step throughA job's life with a processing list
ProducerRedisWorker-1Reaper
LPUSH jobs job-981
BLMOVE jobs processing:worker-1 RIGHT LEFT 5
job-981 (now in processing:worker-1)
worker crashes before LREM
no heartbeat from worker-1 for 30 s
LMOVE processing:worker-1 jobs RIGHT RIGHT
job-981 is back in the queue

7 messages in order. Play them, or step through them one at a time.

Because the job never leaves Redis until LREM, a crash only delays it.

The LREM count of 1 means remove one matching element. LREM matches by the whole string, which is why the worker must send back exactly the payload it received. In Java, we keep the raw string from BLMOVE and pass that same string to LREM rather than serialising the job object again, because a re-serialised JSON with fields in a different order would not match.

4The Reaper and At-Least-Once Delivery

A processing list only helps if someone eventually looks at it. So each worker writes a heartbeat, for example SET heartbeat:worker-1 1 EX 30 every ten seconds. A reaper, which can be a scheduled task in any worker, lists the processing lists, and for every worker whose heartbeat key has expired it moves the jobs back to the main queue with LMOVE processing:worker-1 jobs RIGHT RIGHT until the list is empty. Pushing on the right puts the recovered job at the front of the queue, so it does not wait behind newer work.

This gives at-least-once delivery: every job is processed one or more times. The 'more' comes from crashes at the worst moment. If worker-1 finished the resize, wrote the result, and died just before LREM, the reaper returns the job and another worker resizes the image again. So the handler must be idempotent, which means running it twice has the same effect as running it once. A common way is to record processed job ids, for example SET done:job-981 1 NX EX 86400 before doing anything with side effects, or a unique constraint in the database on the job id, and skip the job when the id is already there.

5What the Pattern Still Leaves to Us

The processing list solves loss, and nothing else. A job that fails with an exception needs a retry policy: count attempts (inside the payload or in a hash keyed by job id) and re-queue with a growing delay, which Redis lists cannot express by themselves, so delayed retries usually go into a sorted set scored by the retry time.

A poison job, one that crashes the worker every time, will cycle forever between the queue and the reaper. After, say, five attempts it should go to a dead-letter list such as jobs:dead, where a person can inspect it. We also want visibility: the length of every processing list, the age of the oldest job in it, and alerts when a list stops shrinking.

Redis Streams with consumer groups give part of this built in. Each delivered entry stays in a pending list with its delivery count and idle time until the consumer acknowledges it with XACK, and XAUTOCLAIM lets a live consumer take over entries that have been idle too long. Delayed jobs, backoff and dead letters are still our job even with Streams.

What each design gives us
ConcernLPUSH + BRPOPBLMOVE + reaperStreams + group
Worker crash mid-jobjob lostjob returned by reaperentry stays pending, XAUTOCLAIM
Delivery guaranteeat-most-onceat-least-onceat-least-once
Retry countnonewe track itdelivery count built in
Dead lettersnonewe build itwe build it
Delayed jobsnosorted set neededsorted set needed

6Follow-up questions

Why does LREM need each job payload to be unique?

LREM finds elements by comparing whole strings, not by position or id. If two different jobs had byte-for-byte identical payloads, for example two 'send the daily report' jobs pushed twice, LREM could remove the wrong copy, and the reaper could not tell which copy belonged to the crashed attempt. Putting a unique job id, such as a UUID, inside every payload makes each element distinct, so LREM removes exactly the job we finished, and the id doubles as the idempotency key.

Could we use a single shared processing list instead of one per worker?

We could, but the reaper would then have no way to know which jobs belong to dead workers and which are being processed right now by healthy ones. With one list per worker, the heartbeat of that worker tells us whether the whole list is abandoned. A shared list would need a timestamp per job, which is exactly what Streams already track for us.

Is BLMOVE safe in Redis Cluster?

Only when both keys hash to the same slot, because a multi-key command in Cluster must touch one slot. We give them a common hash tag, for example {jobs}:queue and {jobs}:processing:worker-1, so the part inside the braces decides the slot.

7Conclusion

In this answer, we saw that BRPOP loses jobs because it deletes the job at delivery, so the only copy lives in the worker's memory. BLMOVE moves the job atomically into a per-worker processing list, LREM removes it after the work, and a reaper driven by heartbeats returns jobs from dead workers, which makes delivery at-least-once. Duplicates then need idempotent handlers, and retries with backoff, dead letters, delayed jobs and monitoring are still ours to build, partly helped by Streams with consumer groups.

What to say in the interviewAbout 90 seconds aloud

Open with

With LPUSH and BRPOP, the job is removed from Redis the moment it is delivered, so if the worker crashes halfway through, the only copy was in its memory and the job is simply gone.

Then, if they want more

Delivery and completion are one event, and they need to be two. The fix is BLMOVE, available since Redis 6.2 as the replacement for BRPOPLPUSH. The worker runs BLMOVE jobs processing:worker-1 RIGHT LEFT 5, which atomically moves the job into its own processing list, and only after the work succeeds does it run LREM processing:worker-1 1 with the exact payload.

Each worker also writes a heartbeat key with a TTL, and a reaper moves jobs from the processing lists of workers whose heartbeat expired back onto the main queue.

That makes delivery at-least-once, so a crash just before LREM means the job runs twice, and the handler has to be idempotent, for example by recording processed job ids or using a unique constraint. Payloads need a unique id so LREM matches the right element.

What it still does not give me is retries with backoff, a dead-letter list for poison jobs, delayed jobs, and visibility of stuck work, so I would add those, or use Streams with consumer groups, which track pending entries and delivery counts for me.

About this answer

Last updated
13 November 2026
Versions it names
Redis 6
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Redis documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain why LPUSH with BRPOP is not reliable and how the BLMOVE pattern with a...": https://scrivio-interview-library.netlify.app/databases/redis-patterns/9e55b6990b/