How to auto start backend if frontend starts?

I want the backend written in Python with fastapi to start when the frontend starts, instead of it only starting when needed. The app seems slow initially without this. How can I do this?

Are you using “suspend” for your backend? It should wake up and respond almost immediately (there’s a bug that causes the 2nd request to block for up to 3 seconds but I’m not sure Fly is aware.)

Not sure, this is what my fly.toml looks like:

app = 'backend-billowing-forest'
primary_region = 'ams'

[build]

[http_service]
internal_port = 8000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '512mb'
cpu_kind = 'shared'
cpus = 1

The python backend is basically a microservice for data processing, so the user runs that when some data processing needs to be done, which is a couple seconds after logging in to the dashboard.

change stop to suspend to see if that helps.

Awesome, works well. Is there any increased cost or something of using this?

No, should be 0 cost unless Fly changes the pricing policy.

Added autoscaling

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