B: randomize order of workers for resource cache
otherwise, it'd be the same workers that constantly have to stream the
volumes (up to some non-determinism in the database results).
randomizing the order should help spread the load.
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"io"
+ "math/rand"
"code.cloudfoundry.org/lager"
"code.cloudfoundry.org/lager/lagerctx"
@@ -352,6 +353,12 @@ func (step *GetStep) findResourceCache(
return nil, false
}
+ // Randomize worker order so that the same worker doesn't have to perform
+ // the streaming constantly
+ rand.Shuffle(len(workers), func(i, j int) {
+ workers[i], workers[j] = workers[j], workers[i]
+ })
+
for _, sourceWorker := range workers {
volume, found, err := sourceWorker.FindVolumeForResourceCache(logger, resourceCache)
if err != nil {
