Skip to content

Instantly share code, notes, and snippets.

@ninowalker
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninowalker/106fb133295867a60971 to your computer and use it in GitHub Desktop.
Save ninowalker/106fb133295867a60971 to your computer and use it in GitHub Desktop.
Celery + Redis trickle backlog
function trickle_backlog() {
queue=$1
backlog=$2
max_depth=$3
host=$4
db=$5
while [ $(redis-cli -h $host -n $db llen $backlog) -gt 0 ]; do
while [ $(redis-cli -h $host -n $db llen $queue) -gt $max_depth ]; do
echo "snoozing..."
sleep 1
done
for i in {1..100}; do
redis-cli -h $host -n $db RPOPLPUSH $backlog $queue > /dev/null
done
date
echo "pushed 100"
done
}
host=...
queue=mqueue_reqs2
q2=mqueue_reqs2_backlog
n=100
db=0
# rename the existing queue
redis-cli -h $host -n 1 rename $queue $q2
# run the trickler in a screen
trickle_backlog $queue $q2 $n $host $db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment