# \[experimental\] Speedy machine creation with overlaybd

**URL:** <https://community.fly.io/t/experimental-speedy-machine-creation-with-overlaybd/18958>\
**Category:** Fresh Produce\
**Tags:** machines\
**Created:** [March 27, 2024, 12:13am UTC](https://community.fly.io/t/experimental-speedy-machine-creation-with-overlaybd/18958 "2024-03-27T00:13:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben-io](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/ben-io/32/35648_2.png) [@ben-io](https://community.fly.io/u/ben-io)\
**Post date:** [March 27, 2024, 12:13am UTC](https://community.fly.io/t/experimental-speedy-machine-creation-with-overlaybd/18958/1 "2024-03-27T00:13:55Z")

</div>

Many docker images are able to start doing useful work before the entire image is downloaded. If you have a particularly large image (e.g. \>1GB, or if you’re running ML workloads), this can have a real impact on how you decide to architect your application.

We’ve been working on a way to make new machine creation faster, using something called [overlaybd](https://github.com/containerd/overlaybd). overlaybd is new container image format that allows us to delay downloading parts of the docker image until they are actually needed. When converting a docker image to this new format, each layer is turned into a block device that stores the changed blocks from the previous layer. overlaybd then merges the layers together, and can randomly access individual blocks in the remote container registry. It runs as a userspace daemon, exposing a virtual block device via [TCMU](https://www.kernel.org/doc/Documentation/target/tcmu-design.txt), and only downloads blocks when they are read. We pass it along to firecracker as the rootfs for the machine.

* * *

To try out lazy-loaded images:

1. Make sure you are on flyctl \>= v0.2.25

```sh
$ fly version
fly v0.2.25 darwin/arm64 Commit: 358c5fcbcbf3b9edfab38ba8f5e305c8b786231e BuildDate: 2024-03-26T04:41:20Z

```

1. Delete your remote builder app, as we have released a new version.

```sh
$ fly apps list | grep builder
fly-builder-bitter-snow-4886 personal suspended	                 	
$ fly apps destroy fly-builder-bitter-snow-4886

```

1. Enable lazy-loaded images in your `fly.toml`

```toml
[experimental]
lazy_load_images = true

```

1. Run `fly deploy`
2. Watch `fly logs` to see how long it takes to start the machine

* * *

This will probably work best for you if you have a large image (\>1GB), and you care about machine creation time (e.g. if you maintain a warm pool of machines). The less amount of data you need to start up, the faster it should be.

This is an experimental, alpha-level feature. Once you try it out, we’d really like to know if it works for you, if you find any bugs, and how it performs with your docker images.

---

<div class="post-metadata">

**Author:** ![charsleysa](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/charsleysa/32/16002_2.png) [@charsleysa](https://community.fly.io/u/charsleysa)\
**Post date:** [April 8, 2024, 2:19am UTC](https://community.fly.io/t/experimental-speedy-machine-creation-with-overlaybd/18958/2 "2024-04-08T02:19:36Z")

</div>

@ben-io hey, crazy idea but, any chance this would allow support for 60GB docker images?

---

<div class="post-metadata">

**Author:** ![ben-io](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/ben-io/32/35648_2.png) [@ben-io](https://community.fly.io/u/ben-io)\
**Post date:** [April 8, 2024, 8:31pm UTC](https://community.fly.io/t/experimental-speedy-machine-creation-with-overlaybd/18958/3 "2024-04-08T20:31:30Z")

</div>

Actually, it probably does already. What’s making your image so large? Note that if you are running a GPU machine we give you a 50GB rootfs instead of 8GB, which is where the image size limitation comes from.

---

<div class="post-metadata">

**Author:** ![charsleysa](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/charsleysa/32/16002_2.png) [@charsleysa](https://community.fly.io/u/charsleysa)\
**Post date:** [April 8, 2024, 10:52pm UTC](https://community.fly.io/t/experimental-speedy-machine-creation-with-overlaybd/18958/4 "2024-04-08T22:52:54Z")

</div>

Just been exploring preloading models into the docker image at build time so that they’re ready to go after machine startup.

I’ve been looking at possibly using ollama with mixtral preloaded and avoiding the need to create volumes for each machine.

---

<div class="post-metadata">

**Author:** ![charsleysa](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/charsleysa/32/16002_2.png) [@charsleysa](https://community.fly.io/u/charsleysa)\
**Post date:** [May 1, 2024, 6:06am UTC](https://community.fly.io/t/experimental-speedy-machine-creation-with-overlaybd/18958/5 "2024-05-01T06:06:56Z")

</div>

@ben-io I’m trying to use this option for deploying an ollama image with llama3 preloaded (around 9.5GB) but I keep getting the following error:

```auto
time="2024-05-01T06:05:06Z" level=error msg="failed to build overlaybd: failed to build \"sha256:05a88d426c377f7de36ce9e541c7b1edb6899b9070dab84b6d5da514fd61fc24\": failed to build tmp_conv/1--05a88d426c377f7de36ce9e541c7b1edb6899b9070dab84b6d5da514fd61fc24: write tmp_conv/1--05a88d426c377f7de36ce9e541c7b1edb6899b9070dab84b6d5da514fd61fc24/0003_sha256:a4f2f307d81738dbd6dfeedfc150a3cb2235ed3f04823a6641a5089f44cf439c/layer.tar: no space left on device"

```

---

<div class="post-metadata">

**Author:** ![ben-io](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/ben-io/32/35648_2.png) [@ben-io](https://community.fly.io/u/ben-io)\
**Post date:** [May 1, 2024, 6:50pm UTC](https://community.fly.io/t/experimental-speedy-machine-creation-with-overlaybd/18958/6 "2024-05-01T18:50:54Z")

</div>

Looks like you ran out of space on the builder. Try expanding the volume:

1. Find the builder app

```auto
❯ fly apps list | grep builder
fly-builder-broken-haze-2872 personal suspended	                 	

```

1. Find the builder volume

```auto
❯ fly vol list -a fly-builder-broken-haze-2872
ID STATE NAME SIZE	REGION	ZONE	ENCRYPTED	ATTACHED VM CREATED AT     
vol_v8mo70jjey6dndlr	created	machine_data 5GB	iad de98	true 78165d2b544968	24 minutes ago	

```

1. Expand it

```auto
❯ fly vol extend -a fly-builder-broken-haze-2872 vol_v8mo70jjey6dndlr -s 30

```

---

<div class="post-metadata">

**Author:** ![charsleysa](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/charsleysa/32/16002_2.png) [@charsleysa](https://community.fly.io/u/charsleysa)\
**Post date:** [May 1, 2024, 11:44pm UTC](https://community.fly.io/t/experimental-speedy-machine-creation-with-overlaybd/18958/7 "2024-05-01T23:44:32Z")

</div>

@ben-io I tried extending the volume to 80GB but it still doesn’t work, and the fly dashboard says only 12GB of the volume is in use. I tried deleting the builder and running it again but still the same issue.

I tried running the deploy locally but it looks like it doesn’t support creating overlaybd images locally.

Here’s the last few log lines of my last attempt:

```auto
2024-05-01T22:36:37.706 app[17816475ce5078] syd [info] time="2024-05-01T22:36:37.706618135Z" level=info msg="fdaa:0:7e:a7b:9076:0:a:800 - - [01/May/2024:22:36:37 +0000] \"GET /flyio/v1/extendDeadline HTTP/1.1\" 202 0"

2024-05-01T22:36:38.348 app[17816475ce5078] syd [info] time="2024-05-01T22:36:38Z" level=error msg="failed to build overlaybd: failed to build \"sha256:4ae533fa5815b2b9c508ebaa1ef3212cba385fd30013183b687a70b9426f859b\": failed to build tmp_conv/1--4ae533fa5815b2b9c508ebaa1ef3212cba385fd30013183b687a70b9426f859b: write tmp_conv/1--4ae533fa5815b2b9c508ebaa1ef3212cba385fd30013183b687a70b9426f859b/0003_sha256:e4c82a20fcbf9d3a45f13f59c4ded14a4ca5e7b160a12f412fef1fa44164919f/layer.tar: no space left on device"

2024-05-01T22:36:38.804 app[17816475ce5078] syd [info] time="2024-05-01T22:36:38.804111875Z" level=info msg="fdaa:0:7e:a7b:9076:0:a:800 - - [01/May/2024:22:31:41 +0000] \"POST /flyio/v1/buildOverlaybdImage HTTP/1.1\" 500 2346"

2024-05-01T22:36:39.203 app[17816475ce5078] syd [info] WARN Reaped child process with pid: 914 and signal: SIGPIPE, core dumped? false

```

And here’s the Dockerfile

```auto
FROM ollama/ollama:0.1.33-rc5

RUN ollama serve & sleep 5 && ollama pull llama3:8b-instruct-q8_0 && kill $!

```
