Created
July 20, 2016 20:37
-
-
Save baverman/5303506cd89200cf246af7bafd569b2e to your computer and use it in GitHub Desktop.
DSQ bench
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
import os | |
from btasks import add | |
COUNT = 10000 | |
if os.environ['QUEUE'] == 'rq': | |
from rq import Queue | |
from redis import Redis | |
# Tell RQ what Redis connection to use | |
redis_conn = Redis() | |
redis_conn.flushdb() | |
q = Queue('normal', connection=redis_conn) # no args implies the default queue | |
for i in xrange(COUNT): | |
q.enqueue(add, i, i+1) | |
elif os.environ['QUEUE'] == 'dsq': | |
import dsq | |
manager = dsq.create_manager('127.0.0.1/0') | |
manager.register('add', add) | |
if __name__ == '__main__': | |
manager.queue.client.flushdb() | |
for i in xrange(COUNT): | |
manager.push('normal', 'add', args=(i, i+1)) | |
elif os.environ['QUEUE'] == 'celery': | |
import celery | |
app = celery.Celery('bench', broker='redis://127.0.0.1:6379/0') | |
app.task(add) | |
if __name__ == '__main__': | |
from redis import Redis | |
redis_conn = Redis() | |
redis_conn.flushdb() | |
for i in xrange(COUNT): | |
app.send_task('btasks.add', (i, i+1), keep_result=False) |
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
#!/bin/sh | |
echo === DSQ === | |
echo -n Push | |
time env QUEUE=dsq python bench.py | |
echo -en '\nProcess' | |
time env QUEUE=dsq dsq worker -bt bench normal | |
echo | |
echo | |
echo === RQ === | |
echo -n Push | |
time env QUEUE=rq python bench.py | |
echo -en '\nProcess' | |
time rq worker -qb normal | |
echo | |
echo | |
echo === Celery === | |
echo -n Push | |
time env QUEUE=celery python bench.py | |
# Celery does not have burst mode | |
# echo -en '\nProcess' | |
# time env QUEUE=celery celery worker -A bench |
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
def add(a, b): | |
a + b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment