Skip to content

How to scale Dagger in production? #6486

Closed

Description

@shykes

Problem

We haven't conclusively answered the question: "what is the best way to scale Dagger in production?". This is in part because there is a wide variety of requirements and preferences, depending on the use case and constraints.

So far there are 2 competing approaches: horizontal scaling and vertical scaling. We have not conclusively decided which one is better, and why.

Solution

Using our collective experience running Dagger in production since the cloak release (0.3):

  1. discuss the different ways to scale Dagger in production
  2. debate horizontal versus vertical scaling, and which is the best for which situation
  3. reach a consensus on best practices
  4. document them clearly
  5. If necessary, change the design and architecture to fit the best practices

Conversation starter

Horizontal scaling vs. vertical scaling: which is best, and why?

Discuss 😁

Activity

  1. nipuna-perera commented on Jan 24, 2024

    @nipuna-perera
    Contributor

    For those of us that can't use dagger cloud yet, is horizontal scaling even an option?

    FWIW, we have a massive Jenkins cluster/s in Kubernetes and we still only scale vertical as that's the only option AFAIK. We find it sufficient for 99% of CICD jobs. There are some exceptional cases that run into issues with running out of resources. The usual culprits like big monorepos.

  2. shykes commented on Jan 24, 2024

    @shykes
    ContributorAuthor

    For those of us that can't use dagger cloud yet, is horizontal scaling even an option?

    FWIW, we have a massive Jenkins cluster/s in Kubernetes and we still only scale vertical as that's the only option AFAIK. We find it sufficient for 99% of CICD jobs. There are some exceptional cases that run into issues with running out of resources. The usual culprits like big monorepos.

    I'm very interested in your vertical scaling setup.

    • Do all Jenkins runners send work to a single Dagger host? Or is it a 1-1 mapping where each Jenkins runner gets its own Dagger host, and each jenkins/dagger host pair are scaled vertically together?
    • How is the right job dispatched to the right host?
    • How do you manage Dagger cache data?
  3. nipuna-perera commented on Jan 24, 2024

    @nipuna-perera
    Contributor

    For those of us that can't use dagger cloud yet, is horizontal scaling even an option?
    FWIW, we have a massive Jenkins cluster/s in Kubernetes and we still only scale vertical as that's the only option AFAIK. We find it sufficient for 99% of CICD jobs. There are some exceptional cases that run into issues with running out of resources. The usual culprits like big monorepos.

    I'm very interested in your vertical scaling setup.

    Sorry I should have clarified. My statement was regarding our current non-dagger setup. Our scaling also is not automatic. Cloudbees Jenkins Core works by distributing it's workloads between many kubernetes nodes. Each job is basically a Pod (Agent) and multiple containers are spun up within that agent to get the job done. The agent gets a static amount of resources based on a user "t-shirt" sizing config (sm, x, xl etc.). Since it's a single pod it never spans beyond a single Node and is resource limited based on the Node size.

    I have run dagger in this setup. What I did was use a docker-in-docker (dind) image to pull down the dagger engine at runtime and perform the given tasks. There is basically no cache. All storage is ephemeral as are the agent pods. This is not a very efficient way to run dagger to say the least but right now that's the only option we have. We are starting to provision "caching" by pushing and pulling from S3. Even that won't be great for dagger but I am planning to utilize it to see what sort of speed gains I can get.

  4. kminehart commented on Jan 24, 2024

    @kminehart

    At Grafana we use this tool we built to build a huge dagger pipeline.

    If you want to see a "huge" dagger pipeline that runs in production feel free to try it out! code here: https://github.com/grafana/grafana-build

    docker run --rm -it --entrypoint=/bin/dagger -v /var/run/docker.sock:/var/run/docker.sock grafana/grafana-build:latest \
      run --silent /src/grafana-build artifacts \
        --github-token=$(gh auth token) \
        --go-version=1.21.5 \
        --ubuntu-base=ubuntu:22.04 \
        --alpine-base=alpine:latest \
        -a targz:grafana:darwin/amd64 \
        -a targz:grafana:linux/amd64 \
        -a targz:grafana:linux/arm64 \
        -a targz:grafana:linux/arm/v6 \
        -a targz:grafana:linux/arm/v7 \
        -a deb:grafana:linux/amd64 \
        -a deb:grafana:linux/arm64 \
        -a deb:grafana:linux/arm/v7 \
        -a deb:grafana:linux/arm/v6 \
        -a rpm:grafana:linux/amd64 \
        -a rpm:grafana:linux/arm64 \
        -a docker:grafana:linux/amd64 \
        -a docker:grafana:linux/arm64 \
        -a docker:grafana:linux/arm/v7 \
        -a docker:grafana:linux/amd64:ubuntu \
        -a docker:grafana:linux/arm64:ubuntu \
        -a docker:grafana:linux/arm/v7:ubuntu \
        --verify \
        --checksum
    

    It's pretty rare that we build every installation method of Grafana (docker, rpm, deb) for all architectures; only whenever we tag a release.

    You can control parallelism with the --parallel flag, defaults to GOMAXPROCS(1)


    Basically we vertically scale a ton to handle this stuff as it's pretty resource intensive. There's lots of parallel go builds with CGO and lots of yarn / nodejs stuff all happening at the same time. The nodes we use are pretty expensive, but they get automatically shut down when not in use. Still, i don't know if they are used very efficiently. They're sized to be able to perform tasks like this when requested, but most of the time they're not really being used even at 50% capacity. That's where I think horizontal scaling would really shine.

  5. shykes commented on Jan 25, 2024

    @shykes
    ContributorAuthor

    @kminehart what's your current approach to managing scaling data, if I may ask? That seems to be a major factor in comparing horizontal and vertical scaling. Specifically: vertical scaling opens the door to much simpler cache data management, because you can rely on machines (or at least their disks) being persistent. The downside is that you have less flexibility in how CPU is allocated to your workloads. You need to configure more upfront ("this job goes to this machine"), and you may run into a wall if your smallest unit of work can't fit in your largest machine.

    Maybe "pet vs. cattle" is a better terminology for what I'm talking about? Stateless vs. stateful machines? Insert terminology bikeshedding here :)

  6. bgroupe commented on Jan 25, 2024

    @bgroupe

    FWIW, k8s has had in-place pod resource updates in alpha since v1.27, so it's now possible to write custom triggers to scale vertically in-place. This would prove to be even easier when support is added to the native Vertical Pod Autoscaler CRD as it will supposedly become the default resize mechanism.

  7. gerhard commented on Jan 25, 2024

    @gerhard
    Contributor

    When I read horizontal vs vertical scaling, I immediately translate this to cluster vs single node. Put differently, by cluster I imagine many smaller instances, or 1 Dagger Engine for each CI job. For single node, I imagine one large Dagger Engine shared by many (all?) CI jobs.

    There is something implicit about the two approaches which I would like to expand on. A cluster, or horizontal scaling, implies ephemeral instances. This is most obvious in the context of GitHub Actions, where each runner starts as a fresh VM, runs a Dagger Engine inside which is dedicated for that run, and then goes away when the job finishes. In our Dagger on Kubernetes Architecture Pattern doc, while the baseline is persistent nodes, we swiftly transition to Optimization 1: Ephemeral, auto-scaled nodes, and then Optimization 2: Shared Cloud Cache. Both of these are important, since that's how we use Dagger in our https://github.com/dagger/dagger repository, a.k.a. dagger-runner:

    # Use our own Dagger runner when running in the dagger/dagger repo (including PRs)
    dagger-runner:
    if: ${{ github.repository == 'dagger/dagger' }}
    runs-on: ${{ inputs.size }}
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-go@v4
    with:
    go-version: "1.21"
    cache-dependency-path: "internal/mage/go.sum"
    - name: ${{ inputs.mage-targets }}
    run: |
    if [ "${{ inputs.dev-engine }}" == "true" ]
    then
    ./hack/dev
    export _EXPERIMENTAL_DAGGER_CLI_BIN="$PWD/bin/dagger"
    chmod +x $_EXPERIMENTAL_DAGGER_CLI_BIN
    export _EXPERIMENTAL_DAGGER_RUNNER_HOST=docker-container://dagger-engine.dev
    fi
    ./hack/make ${{ inputs.mage-targets }}
    env:
    _EXPERIMENTAL_DAGGER_RUNNER_HOST: "unix:///var/run/buildkit/buildkitd.sock"
    _EXPERIMENTAL_DAGGER_CLOUD_TOKEN: "p.eyJ1IjogIjFiZjEwMmRjLWYyZmQtNDVhNi1iNzM1LTgxNzI1NGFkZDU2ZiIsICJpZCI6ICIwYzhmMGY2Yy00YjY1LTRhODktYTI0YS0yN2NjNWNhNzNmNTcifQ.Em92UDP-KmcNd80Y-euTS2IrRkIE8qTisP3SXYkQi3c"

    Note

    There is one twist to this, which I will mention below.

    As for single node, or vertical scaling, the implication is that this is a long-running Dagger Engine host with many CI runners connecting to it via remote TCP. At least that is how I've implemented all my vertically scaled, production Dagger instances.

    With that out of the way, I would like to mention one more thing before I start unpacking the two approaches. I will side-step security concerns & assume that all workloads running on these Dagger Engines are trusted, regardless whether they are running in vertical or horizontal Dagger setups.

    Horizontal Scaling

    flowchart TD
        subgraph CI Runner 1
            cli1[Dagger CLI]
            engine1((Dagger Engine))
            cli1 <--> |local connection| engine1
        end
    
        subgraph CI Runner 2
            cli2[Dagger CLI]
            engine2((Dagger Engine))
            cli2 <--> |local connection| engine2
        end
    
        subgraph CI Runner N
            cliN[Dagger CLI]
            engineN((Dagger Engine))
            cliN <--> |local connection| engineN
        end
    
        cache[(Dagger Cloud Cache)]
    
        engine1 & engine2 & engineN <-.-> |read & write results of operations| cache
    
    Loading

    When using Dagger in GitHub Actions, Gitlab, etc., by default the Dagger Engine gets automatically provisioned in the context of the CI runner. Dagger Engine will use the runner's resources, and the setup scales horizontally: more CI runners means more Dagger Engines, both changing at a ratio of 1:1.

    The challenge with this approach is cache: all those Dagger Engines start with an empty state and each rebuild the cache independently. The solution to this is some form of cache sharing, and that's exactly what Dagger Cloud Cache solves. When connected to Dagger Cloud, each Dagger Engine will pull down the cache for past operations that have been cached, but are not present locally. Once those cached layers are pulled down, they will be re-used from local storage, which speeds everything up.

    The hardest part for this approach is efficient cache sharing between all Dagger Engines that run in parallel. While Dagger Cloud Cache goes to great lengths to make this easier, we are ultimately at the mercy of:

    • networks (latency & throughput constraints)
    • remote storage (the variable performance of object storage)
    • race conditions (if a cache does not yet exist for an operation, multiple nodes may end up running the same operation in parallel)

    We mitigate some of the above items (especially the last one) in our Understand CI Architecture Patterns for Dagger on Kubernetes doc.

    Note

    As mentioned earlier, we do something differently in our https://github.com/dagger/dagger repository. This is it:

    In our case, multiple CI jobs could be scheduled on the same K8s runner node where a single Dagger Engine runs. This means that we have horizontal scaling - we automatically provision as many nodes as needed.

    We also have vertical scaling in the sense that a single large K8s node is likely to run multiple CI jobs at the same time, all using a single Dagger Engine. This is OK, but also inefficient since the slowest CI job will keep this large node running until it finishes.

    In practice, the worst part is that when a job finishes, and the node takes a long time to stop (hours in the worst observed case), we end up paying money for instance time that is not utilised. And since we have provisioned a much larger node than we normally would, which ran for much longer than it should, the total cost ends up being higher than if we had a smaller node which is running permanently.

    Vertical Scaling

    flowchart TD
        subgraph CI Runner 1
            cli1[Dagger CLI]
        end
    
        subgraph CI Runner 2
            cli2[Dagger CLI]
        end
    
        subgraph CI Runner N
            cliN[Dagger CLI]
        end
        
        engine((Dagger Engine))
    
        cli1 & cli2 & cliN <--> |remote tcp connection| engine
    
    Loading

    This means a single Dagger Engine shared among all CI runners. The requirements for this Dagger Engine instance are:

    • fast network (10Gbit or more) with low latency to clients (<100ms RTT)
    • fast local storage (NVMe PCIe 4.0 or better)
    • a CPU that can sustain max boost indefinitely

    While most of the above is also important for horizontal scaling, the network becomes especially important for quickly servicing remote clients. Disk is also important for being able to read and write in parallel, for many different clients.

    If this is in place, and our Dagger Engine is always running, it means that:

    • everything is always ready to service requests, no time wasted booting
    • cache is already primed, which means the highest possible cache hit ratio across all runs, with minimal latency (everything is always local)
    • acts as a container image mirror (may require additional config if pulling many different images)

    The biggest downsides of this vertical scaling approach is having an instance which we need to pay for even when it is not being used. A few solutions which are known to help contain this:

    1. Use prepaid instances (a.k.a. reserved / committed)
    2. Use a vendor (e.g. Hetzner, Leaseweb, Equinix, etc.) which has more cost-efficient pricing model than the big IaaS vendors
    3. Use a vendor (e.g. Fly.io) which provides automatic scale to 0 and sub 1s boot times with local NVMe storage

    The next issue that gets mentioned in the context of this approach is availability & degradation under high load.

    A tried & tested approach to preserving availability is an approach which I refer to as long blue-green. This means that new Dagger Engine versions get deployed on new instances, and we never do in-place upgrades. When the new instance is running, we share the new connection URL - most likely by creating a new secret variable. Clients choose when to migrate by updating the connection secret to the new Dagger Engine, typically as a new PR. If everything works as expected, the change gets merged into the main branch. If not, we work through the problems and try again with the new version. It's simple, gradual & highly effective. I've been using this approach for over a decade in various contexts, it's golden.

    As for high load (a.k.a. noisy neighbour problem), there are no great solutions that I am aware of. Limiting the number of operations by setting --oci-max-parallelism to 80% of available CPUs can help, but the problem is that CPU-heavy tasks (e.g. code compilation) which run as one Dagger operation can use up all CPUs. Maybe there is more that we can do in Dagger to limit how many CPU cores an operation can use. For now, the only pragmatic solution to mitigating noisy neighbours that I am aware of is limiting how many CI jobs can be scheduled to run in parallel on a shared Dagger Engine. This is usually done as a job concurrency config which is CI-specific.

    Which is best? Why?

    I personally had a great experience running single large Dagger Engines on both bare-metal Kubernetes & Fly.io.

    I have 3 constantly running K8s clusters. 2 of them are production (long blue-green), and the other one is an experimental one. All workloads on the clusters are managed by Argo CD.

    For bare-metal Kubernetes, I provision the Dagger Engine using a regular StatefulSet manifest. I run multiple Engine versions since some jobs are still using Dagger 0.6.x, and others are on 0.9.x. I have been using this setup for over 6 months now with minimal issues. Maintenance is a few minutes per month, everything just works.

    The cache is all local, didn't have any issues with it apart from needing to manually delete it when a mounted volume got in a bad state. I could have solved this problem differently, but this was easiest.

    Self-hosted GitHub runners are automatically managed by Actions Runner Controller (ARC), they all connect to the same, always-on, Dagger Engine. The only slow-down happens when multiple operations are compiling code, but this is a minor nuisance at best. The entire setup is low-effort & low-maintenance.

    As for running Dagger on Fly.io, this has all the details https://github.com/thechangelog/changelog.com/tree/690ba13e6978b5d6d494d8c067e61ec6d0f07c00/fly.io/dagger-engine-2023-05-20 . The only downside is that setting up the WireGuard tunnel from GitHub Actions is not always reliable. This has more details: https://community.fly.io/t/fdaa4556-3-wireguard-gateway-intermittent-failure/14597 . This is something that I am looking to improve, but it's not a priority. There is a GitHub Actions fall-back mechanism & I am also thinking of potentially doubling-down on my K8s setup and making that the new default in this context.

    This seems like a good place to stop, leaving redundant Dagger architectures for another discussion.

  8. sipsma commented on Jan 25, 2024

    @sipsma
    Contributor

    @gerhard summarized a lot of the tradeoffs I would have mentioned 🙂 So I'll just add some more thoughts


    For users already invested in a horizontal scaling architecture, they would most likely prefer to not have to re-architect to get caching working with Dagger optimally.

    • I realize this is debatably a different question than "what is the ideal architecture", but it feels like an important consideration nonetheless. Being able to meet users where they are is always nice, all else being equal.

    By far the biggest use case here are managed CI runners (GHA, CircleCI, etc.), but probably also applies to all sorts of corporate infra that already has some investment in some sort of a horizontal scaling type infra.

    Also, with some handwaving, you could also argue that the "set of developer laptops + CI" are a form of horizontal scaling too 🙂 Just in that it's compelling if cache and state can be shared between them.


    I'd actually view cloud cache as somewhat orthogonal to vertical vs. horizontal scaling. Basically, vertical scaling is not contradictory with a remote cloud cache.

    Even though it's not 100% reliant on it like the horizontal scaling case, remote caching still offers some benefits:

    1. When you need to provision a new vertical instance (i.e. blue-green deploy, etc.), it's nice if you don't have to throw out all your cache along the way.
      • There's certainly plenty of shenanigans you can try to do this without a remote cache, but they devolve very quickly in the details into lots of complications+tradeoffs.
    2. Even though vertical instances rely more on local cache, local cache needs to be pruned, so remote cache can still have a role to play as "tier 2" cache for data that has been pruned locally.
      • This is definitely not going to be applicable to every use case by any means, since obviously remote cache needs pruning eventually too.
      • It comes down to economics of remote storage costs vs local disk costs (which in turn is often tied into the size of the instance, at least using AWS as an example), which is obviously quite complicated.
      • It also involves the type of data the user works with. E.g. I'd suspect that users working with lots of huge files might benefit from this more often, especially if their needs in terms of disk space/cpus ratio is fairly high.

    And just generally speaking hypothetically, the features a cloud cache offers expand out to things completely independent of vertical vs. horizontal architecture. This probably gets out of scope of this discsussion, but very briefly, it can be an important backbone for various features around:

    • debugging
    • sharing cache between CI and local development
    • reproducibility/supply-chain-security
    • performance improvements like lazy filesystem image pull-through cache
    • etc. etc. Can expand if needed.

    Point is, I just wouldn't make the strong association of horizontal scaling == cloud cache, vertical scaling == local cache.

  9. aluzzardi commented on Jan 25, 2024

    @aluzzardi
    Contributor

    I'd actually view cloud cache as somewhat orthogonal to vertical vs. horizontal scaling. Basically, vertical scaling is not contradictory with a remote cloud cache.

    Agree on that point. Additionally, I believe the problem can be split/clarified further:

    • Ephemeral vs Persistent storage (as @gerhard mentioned): Horizontal vs Vertical has no bearing on this -- one can have an ephemeral "vertical" instance or persistent horizontal instances
    • In the case of horizontal vs vertical, the perceived advantage of vertical is the persistency, but that can be achieved using horizontal scaling as well
    • The sole difference between vertical and horizontal is the (local) cache hit ratio. With 1 node that's going to be 100%. With 2 nodes, 50% and so on
    • Local cache will eventually spread to all nodes: in a cluster of N nodes, the cache will eventually spread everywhere after N builds (and the hit ratio eventually converging to 100%)

    For users already invested in a horizontal scaling architecture, they would most likely prefer to not have to re-architect to get caching working with Dagger optimally.

    Agreed as well -- IMHO it's a slider. Vertical scaling is a special case of horizontal with 1 node and 100% cache hit. Works for some, doesn't for others.

  10. shykes commented on Jan 25, 2024

    @shykes
    ContributorAuthor

    It's true that "horizontal vs vertical" doesn't adequately capture every dimension of the choice we are facing. I do think there is a binary choice to be made. Of course there is further refinement, variations etc. But fundamentally I believe there are two major architectural patterns, and you either choose one or the other. I am now unsure what to call them.

    The dimensions where they differ are:

    1. Persistence of local storage: ephemeral vs. long-lived?
    2. Job scheduling: one big compute pool, or discrete mapping of certain jobs to certain machines?
    3. Coupling to CI machines: tightly coupled (piggyback) or loosely coupled (standalone)?

    I think (as explained in other comments) how CPU is added to the overall infra (growing existing machines vs. adding more) is not the right dimension because both are potentially applicable in either architecture.

    • Architecture A: ephemeral local storage, one big compute pool, tightly coupled to CI.
    • Architecture B: long-lived local storage, discrete mapping of jobs, loose coupling to CI.

    EDIT: added 3d dimension of difference

  11. samalba commented on Jan 26, 2024

    @samalba
    Contributor

    Quoted from @gerhard:
    The biggest downsides of this vertical scaling approach is having an instance which we need to pay for even when it is not being used. A few solutions which are known to help contain this [...]

    I would also add another solution: stopping / resuming the dagger engine instance on demand (it does not have to be the same instance over time, as long as the local cache fits on an EBS volume which can be the only resource you persist).

    About vertical scaling, it's worth considering that over time, given concurrency and load increase, you may want to have several dagger-engine machines that you round-robin, in this case like Andrea mentioned, it impacts the cache-hit ratio. And doing this means going back to horizontal scaling, but without a remote cache.

    Eventually what we should extract from all of this conversation, is the best production setup for most users. And I see a lots of compelling arguments to always start from a dagger-engine with its cache locally accessible.

  12. sipsma commented on Jan 26, 2024

    @sipsma
    Contributor

    as long as the local cache fits on an EBS volume which can be the only resource you persist).

    @samalba This may seem like a small detail, but it's a good example of the sometimes unobvious tradeoffs here so worth noting: if you want an EBS volume that is both fast and has a lot of space, you will be paying a lot of money for it. And you will be paying for it as long as it exists, whether it's attached to any running instance or not.

    This is as opposed to ephemeral instance storage which is typically fast nvme + comes with the instance itself. The tradeoff there obviously being that it's ephemeral.

  13. skycaptain commented on Mar 13, 2024

    @skycaptain
    Contributor

    TL;DR: For us, the only way to scale is horizontally.

    I would like to share my thoughts. At my company, we're considering daggerizing our CI pipelines for our embedded Linux device software, including all involved lifecycle tools and processes, such as platform components, desktop applications, testing, and more. Our environment is bilateral for the most parts: On one side, we have quick, smaller tasks such as running a linter or building documents. On the other side, we have the heavy-weight jobs such as building our embedded Linux distribution, synthesise FPGA bitstreams, and training AI models.

    For us, stability, reliability, reproducibility and performance are the most critical aspects of our CX infrastructure.

    As @gerhard pointed out, for software building, it mostly comes down to how you handle caching. For smaller jobs, it's often faster to simply rebuild, as compute can be quicker than restoring the cache from remote storage, even with good network latency and throughput. For larger tasks, many tools have their own independent caching mechanisms. For instance, ccache is used for C/C++, Conan to manage pre-built packages, and download and sstate caches for Yocto projects. For these builds, network latency and throughput are equally as important as compute performance.

    Furthermore, caching can be complex and may lead to inconsistent results if your dependency chain is not fully locked and the cache is not shared between all engines on all nodes. To avoid unreliable build results, we currently opt for ephemeral build agents and stateless pipelines with one engine per build job as described by @gerhard. This way we keep our nodes simple (and thus our cluster easily horizontally scalable) and our builds idempotent. This also helps us avoid conflicts with locked cache volumes.

    In my previous company, we used KEDA to spin up a new pod on an AKS when a job is waiting in the build queue, where this pod included both an agent and buildkit engine containers. This allowed us to scale to zero and reduce operational costs. We also defined three different sizes of agents: S, M, and L, and predetermined which job requires which agent size (this is what @shykes mentioned here). We only use the sizing to reserve resources on the cluster (i.e., requests), without imposing any limits. This strategy helps us avoid overprovisioning the nodes and distribute the builds more evenly. A previous approach involved monitoring each build on the cluster and optimizing the parameters accordingly. However, this approach was unsuccessful as the performance deteriorated over time.

    We discovered that vertical scaling is quite limited in software building (even without considering the physical limits of the hardware). As mentioned earlier, we use Yocto to build our embedded Linux, which is essentially a build framework that builds a complete Linux distribution from source. It maximizes performance by parallelizing the build task as much as it can. We often use it to benchmark the build performance of various systems, and we've gained substantial experience by benchmarking many different solutions, including from multiple cloud providers. When evaluating performance, we found the following two aspects most important:

    1. Parallelization on a single machine or node is limited, and beyond a certain point, builds begin to cannibalize each other.
    2. Most software builds still have numerous single-thread bottlenecks. With today's hardware generation, we've found that single-core performance is more crucial than the number of cores. For instance, a consumer-grade 16-core CPU with a high clock speed can be 20-30% faster than a 32-core or 64-core server-grade CPU running the same build. However, having just 16 cores basically only allows us to run a single build job on one node.

    Thus, vertical scaling, if you can call it such here, is essentially about choosing the right hardware for our nodes in the first place and scale horizontally.

    Looking at comparable software like Docker BuildX, it appears they adopt a horizontal scaling approach.

    This, however, only covers our CX infrastructure so far. In the second scenario, we want our developers to use the same cluster to remotely build their local changes. Currently, we achieve this by running a pod for each user indefinitely. Since the engine caches can grow indefinitely, we wipe them periodically. It would be great if we could implement a similar scale-to-zero approach. For example, when running Dagger locally, the CLI creates a local engine container if one doesn't already exist. Ideally, we'd like to replicate this process for a remote K8s cluster, such as spinning up a job pod on demand that shuts down and is removed once the build has completed.

  14. Rots commented on Sep 25, 2024

    @Rots

    Also an aspect that hasn't been mentioned above that matters a lot for using tools in the corporate environment especially for initial PoC and potential migration path is that to my understanding compared to the dagger engine, the Cloud Cache is not open source and I can't self-host it e.g. to use it with internal GitLab runners. So scaling horizontally (multi-node) is not easily available. Ideally there would be an integration to use "external cache" with facilities already provided by GitLab (or other providers).

  15. shykes commented on Sep 25, 2024

    @shykes
    ContributorAuthor

    @Rots yes that is something we are actively developing. We have lowered the priority of our commercial cache offering- we only built it to fill a feature gap in the first place, but didn't anticipate how quickly enterprise deployments started happening. This makes BYOS more important. So we're prioritizing that :)

  16. gerhard commented on Sep 26, 2024

    @gerhard
    Contributor

    We were talking with @nadirollo today, and the following was mentioned:

    This means a single Dagger Engine shared among all CI runners. The requirements for this Dagger Engine instance are: fast network (10Gbit or more) with low latency to clients (sub 1ms RTT)

    I would like to expand on: sub 1ms RTT

    There is a constant, streaming data exchange between the CLI and the Engine. It looks like this:

    Screen.Recording.2024-09-26.at.19.28.12.mp4

    The higher the latency between the CLI and the Engine, the slower this exchange becomes. Also, the CLI usually sends all the source code to the Engine - including the parent directory in certain cases (see #8395 for more details) - which means that there could be a lot of data exchanged and slow networks will result in a slow Dagger experience.

    While this has been mitigated since v0.13.0 (September 11, 2024), CLI to Engine connections used to timeout after 1s: #8328. We are still thinking about a longer-term solution which would make things more performant for local Engines, and still support distant Engines (>1s).

    In a nutshell, the 1ms RTT is NOT a hard requirement. With the latest improvements, the Engine could be 1s away and everything would still work. You will probably notice some slow-down when the Engine is more than 100ms away from the clients, but I don't think that the experience will be terrible. Sub 100ms is recommended (the lower, the better).


    I am going to update my original comment so that it reflects all the changes since January 2024.

  17. gh-antoine-brechon commented on Jan 30, 2025

    @gh-antoine-brechon

    Hi there,
    adding my 2 cents. IMHO horizontal scaling is the way to go with Kubernetes and JIT provisioners like Karpenter, the underlying compute is an abstraction in every way. You can end up with a pool of nodes with very different profiles in terms of compute, still the bin packing will do the magic to accommodate workloads. Of course, for this to work, the usual suspect here is central cache.

    • The first option: having a long-living cache in the cluster, ideally replicated on multiple persistent nodes, while the workers are ephemeral units spawned when needed basically the elastic part. However you can still loose the cache here.
    • The big bertha: The famous tiered storage pattern with cache everywhere and persisted. worker (cache in-memory) <-> cache dedicated nodes on the cluster (in-memory + disk storage) <-> object storage. That would open the door to reusable cache between active clusters, or during blue/green deployments starting pre-warmed.
  18. Kernald commented on Dec 5, 2025

    @Kernald

    Checking in a year later - what is the status of remote caching without Dagger Cloud? I'm looking into migrating a Kubernetes based cluster using Forgejo Actions, partially because of how unreliable the caching unfortunately. Having an on-demand scalable compute with a persistent central cache is definitely appealing.

  19. codethief commented on Dec 5, 2025

    @codethief

    I'm seconding @Kernald's request. (As it so happens, I asked the same question on Discord yesterday.)

    Right now, we're in the process of setting up a single beefy VM to run our Dagger engine on, with a big enough storage volume for caching, and then we'll have our CI runners set up an SSH tunnel to said VM and set _EXPERIMENTAL_DAGGER_RUNNER_HOST accordingly. Anyway, this obviously isn't great as we'll likely run into storage or compute limits at some point but it's the only option that seemed both, simple enough to maintain and to solve our caching needs for now.

    FWIW, my coworker also tried running Dagger in k8s. However,

    • different Dagger engines on different nodes cannot use the same persistent volume for /var/lib/docker, so each node has a separate cache, and
    • setting up a separate persistent volume per node is tricky as nodes are regularly created, updated, or torn down.
  20. ari-becker commented on Dec 26, 2025

    @ari-becker

    On the vertical scaling story, is anyone running a single node using one of Intel's Clearwater Forest 288 core beasts?

    Thinking of an architecture like up-to 280-ish CI runners pinned to their own individual CPU cores, all with access to the same local disk used for cache, thus eliminating the need for remote caching. You then scale further by sharding pipelines that don't benefit much from the same cache onto different machines.

    Is anyone doing this? Are you really keeping all 280+ cores mostly utilized?

  21. cbochs commented on Jan 6, 2026

    @cbochs
    Contributor

    @Kernald a bit of a hack, but given that we can use the buildkit layer caching with _EXPERIMENTAL_DAGGER_CACHE_CONFIG, I created a small interface module which can export volume caches (which aren't included in the buildkit export) to a generic backend (registry, s3, ect.): cbochs/dagger-modules/remote-cache. For example cbochs/dagger-modules/remote-backend provides a OCI registry backend for export/import of volume caches.

    It's able to bridge the gap where you want some persistence across builds that is not only embedded in an OCI layer.

  22. locked and limited conversation to collaborators on Mar 24, 2026
  23. converted this issue into a discussion #12247 on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions