Most of us have used Redis to cache values with an expiry, increment counters, or store related fields in hashes. But Redis can do much more in a large-scale distributed system.
We will cover queues, leaderboards, visitor counts, and background jobs with short code examples and simple explanations.
Examples use Python and redis-py. If you know the basics, skip the quick foundation and start with sets and sorted sets.
Quick foundation: keys, expiry, counters, and hashes
Install the client with pip install redis. Reuse one client per process so connections can be pooled. The examples throughout this article use this client as r:
Set up the shared Redis client
import redis
# Create a pooled client; decode Redis replies as strings.
r = redis.Redis(
host="localhost", port=6379, decode_responses=True,
socket_connect_timeout=1, socket_timeout=2,
max_connections=50,
)
Keys and expiry: SET, GET, TTL, and DEL
Store a session, read it, check its remaining lifetime, and remove it:
r.set("session:abc", "user:42", ex=1800) # Set a key-value pair for 1,800 seconds.
user = r.get("session:abc") # Returns "user:42" before expiry.
remaining = r.ttl("session:abc") # Remaining seconds, initially about 1,800.
r.delete("session:abc") # Remove the key with DEL.
user = r.get("session:abc") # Now returns None: the key is gone.
SET writes a value. ex=1800 sets its expiry in the same command. GET reads the value without changing it. TTL means time to live: TTL returns remaining seconds, -1 for a key without expiry, or -2 for a missing key. The Python method delete sends Redis’s DEL command to remove the key immediately.
Counters: INCR
Count views of an article:
r.set("views:article:redis", 10) # Start this example at 10.
views = r.incr("views:article:redis") # Stored count becomes 11; returns 11.
views = r.incr("views:article:redis") # Stored count becomes 12; returns 12.
INCR adds one and returns the updated integer. If the key is missing, it starts from zero, so the first increment returns 1. Each increment is atomic: competing clients cannot overwrite each other’s increments. The initial SET is just for this example; do not reset the counter on every request.
Hashes: HSET, HINCRBY, and HGET
A hash groups named fields under one Redis key, like a dictionary. Here, player:42 is the key, and name and score are its fields:
# HSET writes fields. mapping is a Python dictionary of field-value pairs.
r.hset("player:42", mapping={"name": "Alice", "score": 10})
# The hash now contains: name = "Alice", score = "10".
score = r.hget("player:42", "score") # Read score: returns "10".
updated = r.hincrby("player:42", "score", 5) # Add 5; stores 15 and returns 15.
score = r.hget("player:42", "score") # Read again: returns "15".
name = r.hget("player:42", "name") # Still returns "Alice".
HSET creates or replaces the supplied fields. HINCRBY adds the given amount to one integer field, leaving the other fields unchanged. A missing numeric field starts from zero. HGET reads one field without changing it and returns None if it is missing.
With decode_responses=True, HGET returns strings such as "15"; HINCRBY returns the updated value as an integer, 15. The initial HSET sets up this example; use HINCRBY for later score increases rather than resetting the score.
1. Sets and sorted sets: membership, position, and scheduling
A set keeps unique members, such as users waiting for an event. A sorted set also gives each member a numeric score, letting us find queue positions, rank players, or read jobs by their scheduled time.
Expand an example below to explore membership, queue positions and leaderboards, or delayed jobs.
Deduplicate waiting users
A set stores unique members:
added = r.sadd("waiting:event:123", "user:42") # Add once; duplicates return 0.
present = r.sismember("waiting:event:123", "user:42") # Check membership.
count = r.scard("waiting:event:123") # Count unique members.
SADD returns 1 for a new member and 0 for a duplicate. The same user can retry joining without increasing the count. Sets do not preserve arrival order.
Show queue position
A sorted set stores unique members with numeric scores:
import time
queue = "queue:{event:123}"
r.zadd(queue, {"user:42": time.time()}, nx=True) # Add only if absent.
rank = r.zrank(queue, "user:42") # Zero-based rank, lowest score first.
position = None if rank is None else rank + 1 # Display positions from 1.
The queue sorts smaller timestamps first. NX preserves the original score on retries. Rank starts at zero, so we add one for display.
Equal scores sort by member value. Client clocks can disagree, so this queue gives approximate arrival order. Use a server-assigned sequence if strict ordering matters. A displayed position is a snapshot, and joining a queue does not reserve inventory.
Build a leaderboard
We want to show the players with the highest weekly scores. Store each player as a sorted-set member and their points as the score:
# Create or update the players' scores in this weekly leaderboard.
r.zadd("leaderboard:weekly", {"alice": 120, "bob": 95, "carol": 150})
# Read positions 0 through 9, highest score first, including scores.
leaders = r.zrevrange("leaderboard:weekly", 0, 9, withscores=True)
# Returns: [("carol", 150.0), ("alice", 120.0), ("bob", 95.0)]
ZADD sets each player’s score. Calling it again for an existing player replaces that player’s score rather than adding to it.
ZREVRANGE reads the sorted set in descending score order:
"leaderboard:weekly"is the Redis key holding the leaderboard.0is the first position, which holds the highest-scoring player.9is the last position to include. Both ends are inclusive, so0through9returns up to ten players.withscores=Truereturns(player, score)pairs. Without it, the result contains only player names.
Our example has three players, so it returns all three, with Carol first. Scores come back as floating-point numbers. Reading the leaderboard does not change or remove entries. Equal scores use reverse lexicographic member order for this descending query.
To add points instead of replacing a score, use ZINCRBY:
score = r.zincrby("leaderboard:weekly", 40, "bob") # 95 + 40 = 135; returns 135.0.
leaders = r.zrevrange("leaderboard:weekly", 0, 9, withscores=True)
# Returns: [("carol", 150.0), ("bob", 135.0), ("alice", 120.0)]
ZINCRBY updates the score atomically, so concurrent point additions do not overwrite each other. Give each week its own key, such as leaderboard:2026-W44, and choose how long to retain old results; the word weekly alone does not reset the data.
Schedule a delayed job
Suppose we want to send an email for order 789 after 60 seconds. A sorted set can hold the job ID, with its scheduled time as the score. Redis stores the schedule; a separate worker checks it and sends the email.
1. Save the job and its scheduled time.
import time
run_at = time.time() + 60 # Current time in seconds + a 60-second delay.
r.zadd("jobs:scheduled", {"email:order:789": run_at})
# Member: the job ID. Score: the earliest time it should run.
2. A worker checks which jobs are due.
now = time.time()
due_jobs = r.zrangebyscore(
"jobs:scheduled",
"-inf", now, # Read scores from the earliest possible time through now.
start=0, num=100, # Return at most 100 job IDs, earliest first.
)
# Before the scheduled time: []
# At or after it: ["email:order:789"] if the job is still in the set.
ZRANGEBYSCORE reads members whose scores fall within a range, including both boundaries. Here, that means jobs scheduled at or before now. Future jobs stay out of the result. A worker can repeat this check every second; execution may be later than the scheduled time if workers are busy.
Finding a job does not execute or remove it. These snippets only schedule and find work. The worker still needs to claim the job, send the email, and record completion. Otherwise, the next check returns the same job again, and two workers can pick it up together.
For production, use a job library or add three steps:
- Claim: use Lua to move a due job into processing with an owner token and deadline, atomically.
- Recover: a lease gives the worker time to finish. Requeue unfinished jobs after the deadline.
- Complete: check the owner token before removing the processing record. Keep a stable job ID and deduplicate retries, since a crash after sending can repeat the email.
Recommendation
Use sets for exact membership and sorted sets for ranks or score ranges. Bound queue size and remove abandoned members. For background work, use Redis Streams, covered in Topic 9, or a library that handles scheduling, retries, and worker recovery. Python examples include Celery and RQ.
2. HyperLogLog: count unique visitors
We need a daily visitor count, but do not need to retrieve every visitor ID.
Count daily visitors with HyperLogLog
key = "visitors:2026-10-27"
r.pfadd(key, "visitor:a", "visitor:b", "visitor:a") # Update the distinct-count sketch.
r.expire(key, 90 * 86400) # Retain this daily sketch for 90 days.
estimate = r.pfcount(key) # Estimate distinct visitors, not total visits.
Repeated IDs do not count as additional distinct visitors. HyperLogLog keeps a compact estimate rather than the original member list. It can estimate millions of unique visitors using only about 12 KB, plus key overhead. Its memory stays small as the visitor count grows. The tradeoff is an approximate count, with a standard error of about 0.81%. HyperLogLog documentation (opens in a new tab)
Recommendation
Use it for traffic analytics. Use a set when you need exact membership, deletion of individual members, or an exact count. Use stable pseudonymous visitor IDs rather than personal data.
3. Bloom filters: avoid pointless database lookups
A URL shortener receives requests for random codes. Most do not exist. A Bloom filter answers definitely absent or possibly present.
Check a short code with a Bloom filter
# Create once: target a 0.1% false positive rate for 1 million entries.
r.execute_command("BF.RESERVE", "shortlinks:filter", 0.001, 1_000_000)
r.execute_command("BF.ADD", "shortlinks:filter", "abc123") # Record this code.
# 1 means possibly present; 0 means absent from this filter.
maybe_exists = r.execute_command("BF.EXISTS", "shortlinks:filter", "abc123")
if maybe_exists:
destination = lookup_shortlink_in_database("abc123") # Verify positive results.
else:
destination = None
The filter targets a 0.1% false positive rate: an absent code can still return “possibly present.” A positive answer always needs the database lookup. For one million codes, this needs about 1.8 MB of filter data, plus overhead. More codes or a lower false positive rate need more memory. Bloom commands require a deployment that supports them, such as Redis 8 or an appropriate RedisBloom installation. Bloom filter documentation (opens in a new tab)
Recommendation
The production catch: a filter can only check codes added to it. Add a new code to the filter before sharing its short URL. If the filter is missing, being rebuilt, or may be out of date, check the database directly so valid links still work. The database remains the source of truth.
4. Bitmaps: track daily activity
One bit can represent whether a user was active on a day.
Map users to bitmap positions
key = "active:2026-10-27"
r.setbit(key, 42, 1) # Mark user 42 active at bit offset 42.
r.expire(key, 30 * 86400) # Retain this daily bitmap for 30 days.
was_active = r.getbit(key, 42) # Read 0 or 1 for this user.
active_users = r.bitcount(key) # Count all bits set to 1.
Bit offset 42 represents user 42. Setting it repeatedly still contributes one to the count. One million dense user positions need about 125 KB of bit payload, plus Redis overhead.
A bitmap uses numbered positions, not user IDs. Your user ID can be a UUID, email, or any other value. Assign each user a unique, permanent integer in your database:
User ID Bit position
"user-alice" 0
"a7f2-uuid" 1
"user-bob" 2
# Look up this user's assigned position in the database.
bit_position = lookup_bit_position("a7f2-uuid") # Returns 1.
r.setbit("active:2026-10-27", bit_position, 1) # Mark this user active.
Recommendation
Use small, consecutive positions. Setting position 1,000,000 needs space for all positions up to it, even if only one user is active. Assign positions once, keep them unique, and do not reuse them while old bitmaps exist. Do not hash user IDs into positions: two users could land on the same bit.
5. Geospatial indexes: find nearby drivers
Use a geospatial index to find drivers near a location, then verify their availability before assigning a trip.
Look up nearby drivers
# Store or update driver:7 at this longitude and latitude.
r.geoadd("drivers:bengaluru", [77.5946, 12.9716, "driver:7"])
# Find up to 10 drivers within 3 km, nearest first, with distances.
nearby = r.geosearch(
"drivers:bengaluru",
longitude=77.6000, latitude=12.9700,
radius=3, unit="km", sort="ASC", count=10, withdist=True,
)
GEOADD stores longitude first, then latitude. GEOSEARCH returns up to ten nearby drivers ordered by distance.
Recommendation
Location alone does not mean a driver is available. Track the last update and online status separately, discard stale results, and atomically assign the chosen driver in the system that owns trips. Individual geo members do not expire automatically; remove offline drivers with ZREM or a cleanup worker.
6. Pipelining: reduce network round trips
A page needs the plan of three users. Sending each request separately adds network waits.
Batch independent reads
with r.pipeline(transaction=False) as pipe: # Batch without transaction isolation.
for user_id in [42, 43, 44]:
pipe.hget(f"user:{user_id}", "plan") # Queue a field read; do not send yet.
plans = pipe.execute() # Send the batch; return results in command order.
The client buffers commands and sends them together. Results arrive in command order. This reduces round trips; Redis still executes each command.
transaction=False makes the intent explicit: batch independent work. Other clients can run commands between ours. redis-py pipelines use transactions by default. Keep batches bounded so queued commands and replies do not consume excessive memory. Pipelines and transactions (opens in a new tab)
7. Lua scripts: read, decide, and write together
Our waiting room allows 1,000 users. Separate “check size” and “join” calls can overfill it when Alice and Bob both see the last free place.
Implement the atomic queue decision
# Prepare a reusable Lua script; calling join_queue runs it on Redis.
join_queue = r.register_script("""
-- Return early if the user already has a queue score.
if redis.call('ZSCORE', KEYS[1], ARGV[1]) then
return 0
end
-- Count members before deciding whether there is room.
if redis.call('ZCARD', KEYS[1]) >= tonumber(ARGV[3]) then
return -1
end
-- Insert the user with their arrival timestamp as the score.
redis.call('ZADD', KEYS[1], ARGV[2], ARGV[1])
return 1
""")
import time
status = join_queue( # Atomically check membership, capacity, and insertion.
keys=["queue:{event:123}"],
args=["user:42", time.time(), 1000],
)
The script returns 0 for an existing member, -1 for a full queue, and 1 for a new join. Redis runs the check and insertion without another client’s commands interleaving. Alice takes the last place; Bob then sees a full queue.
Keep scripts short because they block other command execution on that server while running. Atomic execution does not provide rollback after a runtime error: validate inputs and key types before writing.
Alternative: WATCH with MULTI/EXEC, with client-side retries on conflicts
WATCH detects changes to keys read by the client. MULTI/EXEC then attempts the queued writes; if a watched key changed, the client retries from the read. Use bounded retries for conflicts. Lua is usually simpler for a small decision that depends entirely on Redis data. See the transaction examples (opens in a new tab).
8. Locks and leases: temporary worker ownership
Two workers want to rebuild the same report. A lease gives one temporary ownership until a deadline.
Acquire and release a worker lease
from uuid import uuid4
key = "lease:report:789"
token = str(uuid4()) # Identify this specific lease owner.
acquired = r.set(key, token, nx=True, px=30_000) # Claim if absent, for 30s.
# Delete only if the stored owner token still matches ours.
release = r.register_script("""
if redis.call('GET', KEYS[1]) == ARGV[1] then
return redis.call('DEL', KEYS[1])
end
return 0
""")
if acquired:
try:
rebuild_report(789) # May outlive the lease; see below.
finally:
release(keys=[key], args=[token]) # Compare and delete in one atomic step.
NX acquires only an absent key. The random token identifies this owner. The release script avoids deleting another worker’s lease after ours expires. A renewal must also compare the token before extending expiry. Redis locking pattern (opens in a new tab)
Recommendation
Check current ownership before submitting the result. A worker may still be running after its lease expires and another worker takes over. The system saving the result must check ownership as part of the write.
9. Lists, Pub/Sub, and Streams: distribute work or notifications
Choose a list for a small queue, Pub/Sub for live notifications, or Streams when consumers need retained events and acknowledgements.
Lists: a small work queue
r.lpush("jobs:email", "order:789") # Add a job to the left of the list.
item = r.brpop("jobs:email", timeout=5) # Remove from the right; wait up to 5s.
LPUSH adds on the left; BRPOP waits and removes from the right, giving FIFO order. If a worker crashes after removal, the job is lost.
BLMOVE moves a job from the waiting list to a processing list in one step. Remove it only after the work succeeds. If the worker crashes, a recovery worker can move the unfinished job back for retry. Give each job a unique ID so completion removes the correct job.
Pub/Sub: notify connected servers
# Subscriber process
with r.pubsub() as subscription: # Use a dedicated subscription connection.
subscription.subscribe("catalog:changed") # Listen on this channel.
for message in subscription.listen(): # Wait for subscription events/messages.
if message["type"] == "message":
invalidate_local_catalog(message["data"])
# Publisher process
r.publish("catalog:changed", "product:42") # Broadcast to connected subscribers.
Each connected subscriber receives the broadcast. Disconnected subscribers miss messages, and there is no acknowledgement or replay. Use this for live hints; periodically refresh local data to recover missed invalidations.
Streams: retain events and acknowledge processing
Use Streams to share events across services, track unfinished work, and replay stored history. An online store adds an order.confirmed event to one stream:
orders:events stream
├── email group: worker-1, worker-2 → send confirmation
├── warehouse group: worker-1, worker-2 → start packing
└── analytics group: worker-1 → update sales reports
A consumer group is a team sharing the work. Each group can process the same event independently. Within a group, one worker receives each new event and acknowledges it after success. Unlike Pub/Sub, one shared group does not broadcast to every worker.
Choose where a group starts. Create each group once during setup, then reuse it:
# Start with all events still stored; create the stream if needed.
r.xgroup_create("orders:events", "email-workers", id="0", mkstream=True)
# A different group starts with only events added after its creation.
r.xgroup_create("orders:events", "warehouse-workers", id="$")
# Add an event to the stream, not to a specific group.
r.xadd("orders:events", {"type": "order.confirmed", "order_id": "789"})
id="0" includes retained history. id="$" skips existing events. For example, a new analytics group can use 0 to build reports from past orders.
Read, process, and acknowledge:
# ">" requests events not yet delivered to this group; wait up to 1 second.
batches = r.xreadgroup(
"email-workers", "worker-1",
{"orders:events": ">"}, count=10, block=1000,
)
for stream, entries in batches:
for event_id, fields in entries:
process_event(event_id, fields) # Handle safely if retried.
r.xack(stream, "email-workers", event_id) # Mark complete for this group.
Reading tracks an event as pending, meaning unfinished. XACK marks it complete only for that group; it does not delete it or complete another group’s work. If a worker crashes, add recovery using XAUTOCLAIM to hand old pending events to another worker. Retries can repeat an action, so use the event ID to prevent duplicate effects.
Why keep events? Other groups may still need them, and new services can replay retained history. Even after every group acknowledges an event, it stays stored.
When to delete? Set a retention period, such as seven days, and use XTRIM to remove older entries after checking that important groups have caught up. XDEL removes specific entries. Deleted events are unavailable to every group. Keep permanent orders in the database, and configure Redis persistence for restart recovery. Stream commands (opens in a new tab)
Recommendation
Use Pub/Sub for live messages that can be missed, lists for a simple queue, and Streams to track completed and unfinished work across workers. Workers still need retry recovery and protection against duplicate effects.
10. Running Redis in production
Security: private access and narrow permissions
import os
# Read connection settings from the environment; rediss:// enables TLS.
secure_r = redis.Redis.from_url(
os.environ["REDIS_URL"], # rediss://app-user:password@private-host:6379/0
decode_responses=True, socket_connect_timeout=1, socket_timeout=2,
)
Keep credentials in a secret store, use TLS with certificate verification, restrict network access, and assign ACL permissions by application role and key prefix. For example, an analytics reader should not be able to flush the database. Do not expose Redis directly to the public internet.
Observability: inspect before tuning
Run these commands against your Redis instance. Watch changes over time rather than relying on one snapshot:
redis-cli INFO memory # Memory use and configured memory limit.
redis-cli INFO stats # Evictions, cache hits/misses, refused connections.
redis-cli INFO errorstats # Error counts, including OOM write failures.
redis-cli INFO replication # Replication links and progress.
redis-cli INFO clients # Current connections and blocked clients.
redis-cli SLOWLOG GET 10 # Last 10 logged slow commands.
| Command | What to look for |
|---|---|
INFO memory |
Compare used_memory with maxmemory; used_memory_rss shows physical memory used by the process. Leave headroom. |
INFO stats |
Rising evicted_keys means Redis is removing keys under memory pressure. rejected_connections means connections were refused at the client limit. |
INFO errorstats |
Rising errorstat_OOM means commands are failing because of memory limits. |
INFO replication |
On replicas, check master_link_status. Compare replication offsets and monitor lag over time. |
INFO clients |
Watch connected_clients. Blocked clients can be normal for workers waiting for jobs. |
SLOWLOG GET 10 |
Inspect command names and execution times, reported in microseconds. Network and client waiting time are excluded. |
For cache traffic, INFO stats also reports keyspace_hits and keyspace_misses. Compute hit rate as hits / (hits + misses) over the same interval. Mixed workloads can make this server-wide ratio misleading. INFO fields (opens in a new tab)
Are Stream workers falling behind?
redis-cli XINFO GROUPS orders:events # Group lag and pending count.
redis-cli XPENDING orders:events email-workers # Unacknowledged event summary.
redis-cli XPENDING orders:events email-workers - + 10 # Inspect up to 10 pending events.
lag, when available, counts events not yet delivered to a group. pending counts delivered events not yet acknowledged. The detailed XPENDING output includes idle time in milliseconds and delivery attempts: long idle times can reveal stuck workers. Stream length alone includes retained completed events, so it is not the unfinished-job count. Group metrics (opens in a new tab), pending events (opens in a new tab)
Measure application timeouts, connection-pool waits, and end-to-end latency in your client monitoring. Set alerts from your workload’s normal behavior and load-test before claiming throughput or failover targets.
Persistence and eviction: decide what may disappear
Persistence saves data to disk so Redis can restore it after a restart.
- RDB: saves snapshots. A crash can lose changes made after the last snapshot.
- AOF: records writes. Saving once per second usually risks about a second of recent writes on a crash; actual loss depends on the failure.
Example configuration for background jobs:
# Enable AOF to record writes.
appendonly yes
# Sync writes to disk once per second.
appendfsync everysec
# Set a 2 GB memory limit, leaving additional RAM for overhead.
maxmemory 2gb
# Reject memory-growing writes when full.
maxmemory-policy noeviction
Eviction decides whether Redis removes keys when memory is full. For jobs, noeviction avoids dropping keys to make room, but your application must handle rejected writes. Keys can still expire normally.
For a disposable cache, allkeys-lru can remove less recently used keys instead. Keep caches separate from important job data. Choose the memory limit from your budget and leave extra RAM for Redis overhead. Test backups and recovery. Persistence options (opens in a new tab)
Replication, Sentinel, and Cluster
- Replication: copies data from a primary Redis server to replicas. Copies can lag behind, so failover can lose recent writes.
- Sentinel: monitors a primary and its replicas, and promotes a replica if the primary fails. It does not split data across servers.
- Cluster: splits data across multiple primary servers when one server’s capacity is not enough. Replicas support failover for each primary.
Use Sentinel for failover without splitting data. Use Cluster when you also need to spread data and traffic across servers. Neither guarantees zero lost writes during failover. Replication details (opens in a new tab)
Keep keys together if one command, script, or transaction needs to access them together. In Cluster, matching text inside {} puts keys in the same hash slot, so they stay on the same server:
queue:{event:123}
sequence:{event:123}
Both keys use {event:123}, so a script can update them together. Give other events their own tag. Use a Cluster-aware Redis client so requests reach the right server. Cluster hash tags (opens in a new tab)
Command hygiene, hot keys, and big keys
Avoid commands that read or delete too much data at once.
# Delete only temporary keys, finding them in batches.
for key in r.scan_iter(match="temporary:*", count=100):
r.unlink(key) # Remove the key now; free its value's memory in the background.
bytes_used = r.memory_usage("queue:{event:123}") # Estimate key/value memory bytes.
Use SCAN instead of KEYS to find keys gradually. count=100 suggests a batch size, not a strict limit; results can include duplicates or change while scanning. UNLINK frees value memory in the background, reducing pauses when deleting large values.
- Big key: one key holds lots of data, such as a hash with millions of fields. Read it in batches instead of fetching everything with
HGETALLorSMEMBERS. UseMEMORY USAGEorredis-cli --bigkeysto inspect sizes. - Hot key: one key gets far more requests than others. It can overload its server even in a Cluster, because Cluster does not split a single key across servers.
Quick decision table
| Need | Start with | Main limit |
|---|---|---|
| Related fields | Hash | Bound object size and retention |
| Exact unique membership | Set | Memory grows with members |
| Rank, score range, or due time | Sorted set | Claiming and recovery need more logic |
| Approximate distinct count | HyperLogLog | Cannot retrieve members |
| Cheap absence check | Bloom filter | Positive answers need verification; completeness matters |
| Dense yes/no flags | Bitmap | Largest offset determines size |
| Nearby candidates | Geo index | Freshness and assignment are separate |
| Batch independent commands | Pipeline | No isolation with transaction disabled |
| Small atomic decision | Lua | Keep execution bounded; no error rollback |
| Temporary ownership | Lease | Expiry cannot stop stale workers |
| Live disposable broadcasts | Pub/Sub | No replay |
| Simple FIFO work | List | Add crash recovery explicitly |
| Retained work with acknowledgements | Stream | Recover pending work and deduplicate effects |