Need Help Understanding Multi Process Environments

Hi everyone,

Excited to give Fly.io a try! We’re coming from Heroku (scaling got expensive - fast) and Render (reliability issues).

We have a Django application that also has a few background workers to run some long running updates and to check for data updates.

I added the following to my fly.toml file:

processes
web = "gunicorn backend.wsgi"
worker = "python manage.py rqworker default"
workerhigh = "python manage.py rqworker high"

When I deploy this, it appears to work as I see the startup commands for all three of those processes in the logs.

However, I don’t quite understand where those resources are coming from. Are they “machines”? (I don’t see anything listed under “Machines” though). Do they all share resources that are applied to the main application?

On Heroku/Render, we essentially create an application and then assign “dynos” (servers) to each of the processes. I’m having a hard time understanding where the resources are generated/created when using multiple processes in Fly.io.

Each of those processes is a separate vm, but running on the same host. See: Preview: multi process apps (get your workers here!) - #40 by kurt

Are they “machines”?

VMs.

Do they all share resources that are applied to the main application?

(unless I am mistaken) Each process is entitled to its own cpu/ram alloc.

I’m having a hard time understanding where the resources are generated/created when using multiple processes.

With flyctl --group directive you can target commands at a specific process within a multi-process Fly app. Ex: fly scale vm shared-cpu-2x --group workerhigh -a appname.

You could also scale them out independently: fly scale count workerhigh=8 worker=4 web=2 -a appname.

We used to use multi-process (way back when), but don’t anymore. Unsure what’s the latest on it, tbh.

Btw, an alternative is to run multiple processes in the same VM with a process supervisor to govern 'em all. Ref: Running Multiple Processes Inside A Fly.io App · Fly Docs


Similar: What is the purpose of the "processes" section in [[services]]? - #2 by ignoramous

Should they show up as “machines” in the Fly dashboard? I guess that’s where I’m a bit confused. I’m not seeing these VMs anywhere in the dashboard.

In this particular case, we prefer them to be on separate VMs so we can more easily scale as needed.

PS - Thanks for the help!

Fly machines are a (cheaper and restrictive) alternative to Fly app: That is, a Fly machine is really a http-only Fly app with wake-up-on-lan semantics.

As for why the VMs a multi-process Fly app may spin up aren’t visible in the dashboard… I don’t know. Might be a feature they haven’t thought to implement given multi-process isn’t generally available?

You can see if flyctl commands like flyctl ips private -a appname / flyctl status --all -a appname reveal Instances/VMs allocated to a given multi-process Fly app

We just added docs for this feature: App Configuration (fly.toml) · Fly Docs

This feature needs love, no doubt. The new machines platform will be inheriting this feature soonish, but with more predictable behavior than the old system. Once that starts working, we’ll update the dashboard accordingly.

2 Likes

Should also add to the docs that autoscale doesn’t work when using multiple processes, in which case it’s better to have seperate apps and deploy them in unison in your CI pipeline.