private NodeResources nodeResourcesWith(int nodes,
                                            int groups,
                                            Limits limits,
                                            Load loadAdjustment,
                                            ClusterModel model) {
        Instant now = nodeRepository.clock().instant();
        var loadWithTarget = model.loadAdjustmentWith(nodes, groups, loadAdjustment, now);

        // Leave some headroom above the ideal allocation to avoid immediately needing to scale back up
        if (loadAdjustment.cpu() < 1 && (1.0 - loadWithTarget.cpu()) < headroomRequiredToScaleDown)
            loadAdjustment = loadAdjustment.withCpu(Math.min(1.0, loadAdjustment.cpu() * (1.0 + headroomRequiredToScaleDown)));
        if (loadAdjustment.memory() < 1 && (1.0 - loadWithTarget.memory()) < headroomRequiredToScaleDown)
            loadAdjustment = loadAdjustment.withMemory(Math.min(1.0, loadAdjustment.memory() * (1.0 + headroomRequiredToScaleDown)));
        if (loadAdjustment.disk() < 1 && (1.0 - loadWithTarget.disk()) < headroomRequiredToScaleDown)
            loadAdjustment = loadAdjustment.withDisk(Math.min(1.0, loadAdjustment.disk() * (1.0 + headroomRequiredToScaleDown)));

        loadWithTarget = model.loadAdjustmentWith(nodes, groups, loadAdjustment, now);

        var scaled = loadWithTarget.scaled(model.current().realResources().nodeResources());
        var nonScaled = limits.isEmpty() || limits.min().nodeResources().isUnspecified()
                        ? model.current().advertisedResources().nodeResources()
                        : limits.min().nodeResources(); // min=max for non-scaled
        return nonScaled.withVcpu(scaled.vcpu()).withMemoryGiB(scaled.memoryGiB()).withDiskGb(scaled.diskGb());
    }
For the observed load this instance is initialized with, returns the resources needed per node to be at
the target relative load, given a target node and group count.
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java