How can I run function asynchronously to make calc

2019-08-20 12:08发布

I have to run function 500 times with different arguments on Heroku with hobby plan in my Django app at a specific time. I need to do it in the shortest period of time. I noticed that when I use Heroku Scheduler every task is running parallelly and asynchronously and each of them has own worker. So for example 10 functions ran in this way will calculate results as there would be only 1 ran function. As I have mentioned I need to run 500 functions with different arguments. I could create 500 Heroku schedulers and ran it separately but it seems to me that it's not supported by Heroku or maybe I am wrong? If so maybe someone know how it could be solved in another way?

1条回答
三岁会撩人
2楼-- · 2019-08-20 12:57

Heroku doesn't support running this amount of workers at the same time in hobby plan.

You can use Celery to run this asynchronously with the amount of workers you want. Heroku hobby plan only supports 1 worker, but Celery will run you task in background at least (if that helps).

If you want to go with Celery, there's a guide to start using Celery on Django

查看更多
登录 后发表回答