diff --git a/pkg/environment/apply.go b/pkg/environment/apply.go index 49c69652..ed78ada4 100644 --- a/pkg/environment/apply.go +++ b/pkg/environment/apply.go @@ -194,7 +194,7 @@ func (a *Apply) applyNamespaceDirs(chunkFolder []string) error { chunkStream := util.Generator(done, chunkFolder...) - routineResults := a.parallelApplyNamespace(done, chunkStream) + routineResults := a.parallelApplyNamespace(done, chunkStream, 6) // goroutines are very lightweight and can number in millions, but the tasks we are doing are very heavy so we need to limit this as much as possible results := util.FanIn(done, routineResults...) @@ -206,8 +206,10 @@ func (a *Apply) applyNamespaceDirs(chunkFolder []string) error { return nil } -func (a *Apply) parallelApplyNamespace(done <-chan bool, dirStream <-chan string) []<-chan string { - numRoutines := runtime.NumCPU() +func (a *Apply) parallelApplyNamespace(done <-chan bool, dirStream <-chan string, numRoutines int) []<-chan string { + if a.Options.IsApplyPipeline { + runtime.GOMAXPROCS(3) // this is based on https://github.com/ministryofjustice/cloud-platform-infrastructure/blob/ebafd84ba45a18deeb113d1b57f565141368c187/terraform/aws-accounts/cloud-platform-aws/vpc/eks/cluster.tf#L46C1-L46C58 current max cpu is 4 (for workloads running in concourse) + } routineResults := make([]<-chan string, numRoutines)