From 2982f2e3659342c9107cf5c054d1db5f9043efe9 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Wed, 17 Feb 2016 13:50:06 -0800 Subject: [PATCH] Disable half the workers, freeing half the CPUs --- nomad/leader.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nomad/leader.go b/nomad/leader.go index ce60966f4e44..229a9f2191ef 100644 --- a/nomad/leader.go +++ b/nomad/leader.go @@ -98,10 +98,13 @@ WAIT: // previously inflight transactions have been commited and that our // state is up-to-date. func (s *Server) establishLeadership(stopCh chan struct{}) error { - // If we have multiple workers, disable one to free processing - // for the plan queue and evaluation broker - if len(s.workers) > 1 { - s.workers[0].SetPause(true) + // Disable workers to free half the cores for use in the plan queue and + // evaluation broker + if numWorkers := len(s.workers); numWorkers > 1 { + // Disabling half the workers frees half the CPUs. + for i := 0; i < numWorkers / 2; i++ { + s.workers[i].SetPause(true) + } } // Enable the plan queue, since we are now the leader @@ -363,7 +366,9 @@ func (s *Server) revokeLeadership() error { // Unpause our worker if we paused previously if len(s.workers) > 1 { - s.workers[0].SetPause(false) + for i := 0; i < len(s.workers) / 2; i++ { + s.workers[i].SetPause(false) + } } return nil }