rq / django-rq

A simple app that provides django integration for RQ (Redis Queue)
MIT License
1.83k stars 286 forks source link

django worker slow? #72

Open ghost opened 10 years ago

ghost commented 10 years ago

I have a very simple task:

@job
def log_info():
    logger.info('Job running')

Queuing this task 500 times nearly takes 2 minutes to process with a single worker.

for i in range(500): tasks.log_info.delay()

I guess its because of the issue described in the Performance notes here. Is django-rq is setting up the django environment for every single job?

zoidyzoidzoid commented 10 years ago

Have you tried using a custom worker and seen if it improves performance?

ghost commented 10 years ago

Not sure if I came across custom workers, but pretty sure I haven't tried.

zoidyzoidzoid commented 10 years ago

Sorry, I used the wrong terminology.

The Performance notes that you linked to suggest a custom rqworker script, that is supposed to improve performance by preloading imports, so maybe setting up the django environment once.

I'm considering trying it since I have the same problem you're experiencing.

jorgecarleitao commented 9 years ago

I believe yes, django-rq is setting its env every call, like rq. You can easily test it by having a print('Hello') in settings.py. If print is being called after each job, then you have your answer.

I'm not sure this is an issue of django-rq though. As pointed out in rq docs that you link, it was a design decision to avoid memory leaks. Django-rq is backing it.

satyrius commented 8 years ago

@jorgecarleitao print will be once btw