Autostart EdgeDB instance not working

I have a instance of edgedb up and running (following these docs), starts and stops correctly when prompted through flyctl. I have set the following params in the fly.toml:

auto_start_machines = true
min_machines_running = 0

This turns off all machines when not in use, which is fantastic for cost saving as it is only used infrequently. However, when the machine is auto-stopped, it does not re-start again when i attempt to connect via app.internal:8080.

My assumption was that this should happen when a request is made on the app, however this never seems to happen (no machines ever start). DIG resolved the internal URL fine and other fly.io apps are able to connect fine when a machine is actually running.
Any ideas of what is going wrong here?

Hi @growberry! Connecting to a Machine directly over your private network (6PN) won’t be able to automatically start it, unfortunately. Autostart/autostop works only when network traffic is first proxied/load-balanced by our edge proxy, since the proxy is what’s actually responsible for starting and stopping your app’s Machines as needed.

It’s possible to use the proxy for internal services, though! You can configure [[services]] and/or [http_service] as usual in your fly.toml, but then assign the app a private rather than a public IP address. More on that here. Once configured, connect to your app via the private IPv6 address or with the app.flycast domain name. That traffic will then go through the proxy first, and the proxy should autostart your Machines as necessary.

You need to connect via the proxy, ie app.flycast:8080, to wake up the machine.

Thank you both, can confirm this works, and due to the bolstered requirements to run a edgedb instance, this will save a good bit of money over time!

For future reference, this is the services section in the toml I’m using

[[services]]
    http_checks = []
    internal_port = 8080
    auto_stop_machines = true
    auto_start_machines = true
    min_machines_running = 0
    force_https = false
    processes = ["app"]
    protocol = "tcp"
    script_checks = []

    [services.concurrency]
        hard_limit = 25
        soft_limit = 20
        type = "connections"

    [[services.ports]]
        port = 5656

    [[services.tcp_checks]]
        grace_period = "1s"
        interval = "15s"
        restart_limit = 0
        timeout = "2s"

then just connect with the ENV - EDGEDB_DSN=edgedb://edgedb:{{password}}@{{app_name}}.flycast

I also removed all of the public IPs so to ensure it’s only accessible to internal apps.

Thanks again!

1 Like

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