Why optimization matters (and how lazy pulling helps)
How fast an agent or service starts is directly related to how long it takes to pull and start its container image. Images that are large, slow to decompress, have unnecessary files or dependencies can take significantly longer to start. Stargz improves startup time by enabling lazy pulling. This allows the container to start before the full image is downloaded. Only the files needed during initial setup are fetched and the rest of the image is streamed on demand if/when needed.How MeshAgent uses your images
- When a room starts, MeshAgent pulls and runs the images for every room service attached to that room. Pull time directly affects time-to-ready.
- If you redeploy a room service, MeshAgent detects the change and reconciles the running container automatically.
- If you redeploy a project service, restart the room for the change to take effect in that room.
- If you are deploying a CLI ChatBot or VoiceBot, use the
meshagent/clibase image. It is already optimized and supports the standard flags (tools, rules, room-rules, etc.), so you usually do not need to build a custom image. - If you reference an external service you host yourself, MeshAgent skips pulling/running a container and just routes to your endpoint. Container optimizations only matter for services you package with a container image.
What Stargz is and how we use it
We publish images in an eStargz/stargz format and run with the stargz snapshotter (a containerd plugin). This makes image layers seekable (the runtime can jump directly to specific files instead of downloading the whole layer first):- Instead of downloading and decompressing an entire layer before start, the runtime lazily fetches just the files that are actually touched at startup.
- Startup is faster (lower cold-start latency) and data transfer is smaller, especially for larger Python/Node/ML stacks.
- Lazy pulling requires the containerd stargz-snapshotter; if it is not present, the image pulls and runs like a normal OCI/Docker image (just without the lazy-pull speedup).
- MeshAgent does not need a special tag or flag: the runtime decides. If the host has the stargz snapshotter, your stargz-compressed image is lazily pulled; if not, it is pulled normally.
We publish
-esgzimage variants that are optimized for lazy pulling via the stargz snapshotter. On environments without the snapshotter, these-esgzimages behave like normal images; they just don’t get the lazy-pull speedup.
- Build stargz variants alongside the normal tags.
- Provide prefetch lists (the small set of files the agent touches during boot: entrypoint, deps, config) so the snapshotter pulls only what is needed up front.
When deploying custom services
- Use MeshAgent base images when possible (they already include stargz builds with
-esgztag). If building your own image, we recommend optimizing it using stargz so your service can start quickly. - Keep images slim: install only what you need, clean caches, and avoid large unused assets.
- You can either publish only a stargz-optimized image (recommended — avoids storing two images in your registry) or publish both a standard and an optimized version. To create stargz images we recommend using nerdctl here and ctr-remote here.
Related Topics
- Packaging services: Field reference and examples for packaging a service.
- Deploying services: Ship and update services from the CLI or Studio.
- Room services example: Deploy a service scoped to a specific room.
- Project service example: Deploy a service for a project (available in all rooms in the project)