Skip to content

Commit

Permalink
Merge pull request #812 from hashicorp/f-disable-cores
Browse files Browse the repository at this point in the history
Disable half the workers, freeing half the CPUs, on the leader
  • Loading branch information
dadgar committed Feb 17, 2016
2 parents daf1231 + 2982f2e commit 36675f7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions nomad/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 36675f7

Please sign in to comment.