This repository has been archived by the owner on Sep 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use goroutine pool within autoscaler to limit concurrency.
Previously the internal autoscaler iterated through the scaling policies and launched a go routine to run the autoscaling check process. There were no limits on the number of routines which could lead to overloading on the Nomad API. This change introduces a goroutine pool in order to limit the number of concurrent scaling threads. The number of threads is configurable via the CLI, with a default of 3. When all threads are in use, the iteration will block until additional work can be consumed. There is a timelimit of the execution, currently set to 60's which we may want to make configurable in the future.
- Loading branch information
Showing
21 changed files
with
1,640 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ package autoscale | |
|
||
type Config struct { | ||
ScalingInterval int | ||
ScalingThreads int | ||
StrictChecking bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package autoscale | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAutoScale_createWorkerPool(t *testing.T) { | ||
testCases := []struct { | ||
autoscaleStruct *AutoScale | ||
expectedThreads int | ||
testName string | ||
}{ | ||
{ | ||
autoscaleStruct: &AutoScale{cfg: &Config{ScalingThreads: 100}}, | ||
expectedThreads: 100, | ||
testName: "check worker pool number of concurrent threads", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
pool, err := tc.autoscaleStruct.createWorkerPool() | ||
|
||
assert.Nil(t, err, tc.testName) | ||
assert.Equal(t, tc.expectedThreads, pool.Cap(), tc.testName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.