Review request

Podcast clip generator times out on the first request after a quiet hour

Solved · 9 views · asked by kai_makes · edited

Repo or live app

github.com/kaitanaka/clipcast

Unsure about: DeploymentPerformance

Upload an episode, get shareable clips. Windsurf set it up as one container that runs ffmpeg and serves the site. It scales to zero when idle. The first person to visit after a quiet stretch waits about 40 seconds and usually gives up, then everything is fine for the rest of the day.

Comment

2 answers

Marked as helpful by the asker
jonas_k · edited

Two separate costs are stacked in that 40 seconds and they need different fixes.

The wake itself is a few seconds at most. What makes it 40 is that your container carries an ffmpeg-capable image, and a big image is slow to pull and slow to start. Check your image size; these often land above a gigabyte because the build copies the whole build context. A multi-stage build with only the runtime layer usually cuts it by most.

Then stop scaling the web part to zero. Keep one small always-on machine for the site and move the actual encoding to a separate worker that can scale from zero, because nobody minds waiting for a clip they just requested. A visitor waiting on a homepage is a lost visitor, a job waiting in a queue is normal.

Comment
ben_mobile · edited

Whatever you do about the cold start, return something within a second. Accept the upload, write a row with status queued, respond with an id, and poll or subscribe for the result. Right now the request holds open through the whole encode, so any slow episode looks identical to a dead server and the browser eventually gives up on its own.

Comment