Should I use plain Python code or Celery? Django. -
i have heavy function (a lot of calculations done) outputs individual number each user in django project. number changes little on time minimize server load thought running function once day, save output , reference output. know these kinda things handled celery
package requires lot of site packages , modules thought writing simple function like:
x0 = #last.time function called x1 = datetime.now if x0-x1 > 1 day: def whatever(): .... x0 = datetime.now return ....
i keep code clean , not install packages not required know if there downsides "just" using python or gain when celery
. task not need asynchronous don't care that. there clear "use case" when celery should used , when not? there performance loss/gain?
i hope can explain properly.
celery clear winner explain pros , cons.
pros:
you can control celery django easily. running celery task, cancelling task, checking state/progress of task can done within django.
a periodical task running celery simple, register task django run celery worker , voila done. no need mess around crontab or background processes.
celery easy setup , run. might know if have gone through introduction of celery.
cons
one of cons need have @ least 1 result backend either redis, rabbitmq or other 1 running celery queuing purposes. although rabbitmq not heavy need install once.
one more celery worker takes memory won't issue if on server, on local memory consumption might seem high you.
i suggest celery because provide more control on task rather simple background process.
Comments
Post a Comment