Last active
August 29, 2015 14:13
-
-
Save ninowalker/106fb133295867a60971 to your computer and use it in GitHub Desktop.
Celery + Redis trickle backlog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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