Cannot modify concurrency for apps using the machine API

Hej all :wave:

First of all, fly has been amazing so far.

We are evaluating a possibility to launch machines via the machine API and have them launched/scaled based on concurrency, however we are having challenges in modifying the concurrency settings via the .toml that’s generated using fly m launch. Ideally we want to run a machine as a worker for a single request/task.

# fly.toml file generated for node-web-6 on 2022-11-02T10:10:18+01:00

app = "node-web-6"
primary_region = "ams"

[build]

[http_service]
  internal_port = 8080
  force_https = true

[env]

[deploy]

We have also tried creating an app using the fly m api-proxy via

curl -i -X POST \
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \
"http://${FLY_API_HOSTNAME}/v1/apps" \
-d '{
  "app_name": "node-web-4",
  "org_slug": "org-name",

  "config":{
  "env": {},
    "experimental": {
        "allowed_public_ports": [],
        "auto_rollback": true
    },
    "kill_signal": "SIGINT",
    "kill_timeout": 5,
    "processes": [],
    "services": [
        {
            "concurrency": {
                "hard_limit": 1,
                "soft_limit": 1,
                "type": "requests"
            },
            "http_checks": [],
            "internal_port": 8080,
            "ports": [
                {
                    "force_https": true,
                    "handlers": [
                        "http"
                    ],
                    "port": 80
                },
                {
                    "handlers": [
                        "tls",
                        "http"
                    ],
                    "port": 443
                }
            ],
            "processes": [
                "app"
            ],
            "protocol": "tcp",
            "script_checks": [],
            "tcp_checks": [
                {
                    "grace_period": "1s",
                    "interval": "15s",
                    "restart_limit": 0,
                    "timeout": "2s"
                }
            ]
        }
    ]
    }
}'

However when the app is created but those concurrency settings default to

"concurrency": {
                "hard_limit": 25,
                "soft_limit": 20,
                "type": "connections"

which we verified via fly config display -a node-web-4

Could you please assist us with a way to update the concurrency?

Thank you so much!

Hey, the fly launch, fly machine launch or even fly deploy commands are ready yet ready for machines. It’s something we still trying to figure out, so it’s not surprising that fly.toml isn’t working for you. Your best bet(at least for now) is to use fly machine create and fly machine update to manage individual machines.

# fetch vm-ids
fly m list -a <machine-app-name>
# fetch config
fly m status <vm-id> -d -a <machine-app-name>

…should accurately blurt out the config specific to that machine-vm. Each machine-vm can be run with a different config and so you’d not find a VM’s config values in the app’s overall config (if that makes sense…).

Also: flyctl deploy does not honour all entries in config for machine apps - #2 by eli


Edit: Btw, I don’t think Fly’s edge proxy can load balance (using services.concurrency) among multiple machines (of an app) in the same region, yet (but will eventually, as Machine’s where Fly is betting its resources on): Preview: Postgres on Machines ( Fly Apps V2 ) - #2 by ignoramous (which unfortunately results in at least 2x the costs for us than it should).