The Disk Isn't Yours: Four Ephemeral-Host Myths and a Restart Drill
You deploy a small worker on a free server. It runs fine for a week. Then the host restarts, and the worker wakes up confused. This post is about that morning. Not the deploy. The wake-up. The claim I keep hearing "It's just a tiny script. Local files are enough." That sentence is usually true until the first restart. Free hosts are cheap because something is disposable. Usually it is you. Below…
The article discusses four common misconceptions about using free server hosts for running workers and provides a checklist to avoid these pitfalls. The first myth is that the disk is a database, which is false because writes to local files like /data or ./state disappear when the container is deleted. The corrected mental model treats local disk as a cache, not a source of truth, and stresses that local files should be recomputable or lossy.
The second myth is that a process that starts once keeps running, but this is incorrect because free hosts may idle, suspend, or be terminated unexpectedly. To avoid this, design the process with a supervisor that can handle shutdowns and restarts.
The third misconception is that a crash leaves clean state, but this is not always the case. A job may write output and then die before acknowledging upstream, creating a result without a corresponding job. To prevent this issue, make state transitions explicit and include a reconciliation pass at boot. The corrected model suggests writing results first, marking them durable, and acknowledging upstream last. If these steps can't be atomic, they should be replayable.
The fourth myth is that cold start is just a number, but it isn't. The second start is different from the first due to empty caches, cold connections, and any warm-up routines that run again. To measure the true cost, record time-to-first-useful-work instead of time-to-boot. Log timestamps for process start and the first job completion to compare restarts and identify the gap in cost.
The article concludes with a restart drill consisting of four steps: writing a boot marker, making one job replay-safe, reconciling at boot, and recording observations. This drill helps users understand whether local disk is persistent for their host, identify gaps in acknowledgement, and assess the time-to-first-useful-work. By following the checklist and conducting the restart drill, users can better manage workers on free server hosts and avoid common pitfalls.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.