
This guide shows how to preload large files onto volumes using forking to improve startup performance. This is especially useful for apps with big model files, binaries, or databases.
Overview
If your app needs large local files like ML models, SQLite databases, or game assets, you’re probably copying them into place at boot. Maybe you bake them into your image, or have your app download them on first run. This works, but it has downsides:- Slow startup times: waiting for multi-GB file downloads.
- Wasted bandwidth: each new machine pulls the same data.
- Image bloat: large files increase your OCI/Docker image size.
Why use this pattern?
You’re cloning machines and want them to boot fast, with all their large files already in place. This isn’t about long-term persistence (though volumes can be used for that, too). It’s about getting cold-start performance close to warm-start, by skipping the “download half the internet” phase of your boot process. It’s especially useful when:- You’ve already run a setup step once and don’t want to repeat it.
- Your app reads large files but doesn’t modify them.
- You’re scaling up on demand and startup time matters.
How volume forking works
When you fork a volume:- Data is copied from the source volume, block-for-block.
- Forked volumes are usable immediately, even while they are in the hydrating state, thanks to lazy fetching (a system where data blocks are only fetched from the source volume when your app actually tries to read them).
Example: cloning a machine with preloaded data
1. Make sure the source volume you want to fork is available
2. Fork the volume
vol_new_id.
3. Clone the machine and attach the forked volume
What to know
- Forks aren’t instant behind the scenes. You can read from them immediately, but the full copy happens in the background. Disk I/O might be slower until replication finishes.
- Data is a snapshot, not a live link. Changes to the original after forking don’t show up in the copy (and vice versa).
- You can fork cross‑region. The
--regionflag allows you to target another region for the fork. If you skip it, the volume ends up in the same region by default. Cross-region forks are expected to hydrate more slowly, since all data must be replicated over the network between regions. - Forks have storage costs. As blocks are fetched or written, forked volumes grow. Keep an eye on storage usage costs if you fork a lot.
(Optional) Automate it in CI
If you’re scripting deploys or scaling machines dynamically, you can fold this pattern into a CI job or automation script. Here’s a rough sketch:fly machine operations, this fits right in.
Related reading
- Fly Volumes overview
- Create and manage volumes
- Volume states
fly volumes forkreference