Machines being suspended while doing work

I have a rust app that handles transcoding of files that users upload and then subsequently sends SSE progress events while transcoding. Half way through the process, the machine running the transcode process gets automatically suspended:

Config:

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = 'suspend'
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[[vm]]
  memory = '4gb'
  cpu_kind = 'performance'
  cpus = 2

Logs from the machine:

2025-05-12 02:03:15.949	
Virtual machine has been suspended
2025-05-12 02:03:07.999	
App app-transcoder has excess capacity, autosuspending machine 48e2d60f395548. 1 out of 2 machines left running (region=sjc, process group=app)
2025-05-12T09:03:07.707255Z  INFO hls_transcoder::api::handlers::events: Sent progress SSE event for job d5521d5d-7b30-47da-ae2c-0c6d87427da1
2025-05-12T09:03:07.707215Z  INFO hls_transcoder::api::handlers::events: Received progress update for job d5521d5d-7b30-47da-ae2c-0c6d87427da1
2025-05-12T09:03:07.638903Z  INFO hls_transcoder::job::progress: Job d5521d5d-7b30-47da-ae2c-0c6d87427da1 progress: 35.774063% - transcoding variant 2/3

Obviously I can turn off auto start/stop, but that means running these machines 24/7 and I’d prefer to only run them when needed. However, I can’t understand why this is happening and currently it suspends machines in the midst of user’s transcoding jobs.

1 Like

I think that the SSE connection should keep the machine alive.

If you have custom needs (for example background processing), disable auto_stop_machines and have your program exit with an exit code of 0 and your machine will be restarted when it receives the next request. See: Autostop/autostart Machines · Fly Docs

I would’ve thought the SSE connection would’ve, but it isn’t. The machine will get suspended when processing a job even with an open SSE connection that is sending progress updates to a user.

We will build in a method for the machine to exit (0) when it idles, and then just leave autostart on, but I’m still a bit confused why an open SSE connection would lead a machine to get suspended.

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