fly.toml for Complex Django App

I have several processes in my Django app, namely:

  • web
  • celery queue A
  • celery queue B
  • celery beat
  • celery flower

I want to configure such that the web, celery queue A, and celery queue B has minimum of 2 machines each, but EXACTLY one for celery beat and celery flower processes.

Any idea how to write the config file?

Hey @aarroisi!

You’ll want to define all your procs in a processes section in your fly.toml which would look something like this:

[processes]
  web = "gunicorn --bind :8000 --workers 2 hello_django.wsgi"
  celery_beat = "your-celery-beat-command"
  celery_flower = "your-celery-flower-command"
  celery_queue_a = "your-celery-queue-a-command"
  celery_queue_b = "your-celery-queue-b-command"

From there, use fly scale count to control the number of machines per process. We have some docs that break down in greater detail how to run multiple process groups in an app: Run Multiple Process Groups in an App · Fly Docs

Hope this does what you need it to.

1 Like

Thanks for the quick reply

Just to clarify, so the number of scale is not possible to be defined in fly.toml? I kinda want to define number of scale for each process/machine in the fly.toml. So, when I run fly deploy, it will always follow the last settings on scale?

Thanks.

You can always set a make deploy shortcut that would enable you do to so.
Example, create a Makefile in the root of your project, and inside you’d have:

deploy: 
   fly deploy  
   fly scale count web=1 celery_beat=1 celery_flower=1 celery_queue_a=1 celery_queue_b=1

Then just run make deploy.
You could even make it more dynamic, scripting something to get the number of machines from a fly_scale.json or even from some field that you place inside the fly.toml file.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.