Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new knob for configuring burst capacity. #4433

Merged
merged 2 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions config/config-autoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ data:
# to achieve efficient resource usage (VPA CPU minimum is 300m).
container-concurrency-target-default: "100"

# The target burst capacity specifies the size of burst in concurrent
# requests that the system operator expects the system will receive.
# Autoscaler will try to protect the system from queueing by introducing
# Activator in the request path if the current spare capacity of the
# service is less than this setting.
# If this setting is 0, then Activator will be in the request path only
# when the revision is scaled to 0.
# If this setting is > 0 and container-concurrency-target-percentage is
# 100% or 1.0, then activator will always be in the request path.
# Negative settings are invalid.
target-burst-capacity: "0"

# When operating in a stable mode, the autoscaler operates on the
# average concurrency over the stable window.
stable-window: "60s"
Expand Down
9 changes: 9 additions & 0 deletions pkg/autoscaler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type Config struct {
// Target concurrency knobs for different container concurrency configurations.
ContainerConcurrencyTargetFraction float64
ContainerConcurrencyTargetDefault float64
// NB: most of our computations are in floats, so this is float to avoid casting.
TargetBurstCapacity float64

// General autoscaler algorithm configuration.
MaxScaleUpRate float64
Expand Down Expand Up @@ -93,6 +95,10 @@ func NewConfigFromMap(data map[string]string) (*Config, error) {
key: "container-concurrency-target-default",
field: &lc.ContainerConcurrencyTargetDefault,
defaultValue: 100.0,
}, {
key: "target-burst-capacity",
field: &lc.TargetBurstCapacity,
defaultValue: 0,
}, {
key: "panic-window-percentage",
field: &lc.PanicWindowPercentage,
Expand Down Expand Up @@ -157,6 +163,9 @@ func validate(lc *Config) (*Config, error) {
if lc.ScaleToZeroGracePeriod < 30*time.Second {
return nil, fmt.Errorf("scale-to-zero-grace-period must be at least 30s, got %v", lc.ScaleToZeroGracePeriod)
}
if lc.TargetBurstCapacity < 0 {
return nil, fmt.Errorf("target-burst-capacity must be non-negative, got %f", lc.TargetBurstCapacity)
}

if lc.ContainerConcurrencyTargetFraction <= 0 || lc.ContainerConcurrencyTargetFraction > 1 {
return nil, fmt.Errorf("container-concurrency-target-percentage = %f is outside of valid range of (0, 100]", lc.ContainerConcurrencyTargetFraction)
Expand Down
22 changes: 22 additions & 0 deletions pkg/autoscaler/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestNewConfig(t *testing.T) {
"max-scale-up-rate": "1.0",
"container-concurrency-target-percentage": "0.5",
"container-concurrency-target-default": "10.0",
"target-burst-capacity": "0",
"stable-window": "5m",
"panic-window": "10s",
"tick-interval": "2s",
Expand All @@ -48,6 +49,7 @@ func TestNewConfig(t *testing.T) {
EnableScaleToZero: true,
ContainerConcurrencyTargetFraction: 0.5,
ContainerConcurrencyTargetDefault: 10.0,
TargetBurstCapacity: 0,
MaxScaleUpRate: 1.0,
StableWindow: 5 * time.Minute,
PanicWindow: 10 * time.Second,
Expand All @@ -63,6 +65,7 @@ func TestNewConfig(t *testing.T) {
"max-scale-up-rate": "1.0",
"container-concurrency-target-percentage": "50",
"container-concurrency-target-default": "10.0",
"target-burst-capacity": "0",
"stable-window": "5m",
"panic-window": "10s",
"tick-interval": "2s",
Expand All @@ -73,6 +76,7 @@ func TestNewConfig(t *testing.T) {
EnableScaleToZero: true,
ContainerConcurrencyTargetFraction: 0.5,
ContainerConcurrencyTargetDefault: 10.0,
TargetBurstCapacity: 0,
MaxScaleUpRate: 1.0,
StableWindow: 5 * time.Minute,
PanicWindow: 10 * time.Second,
Expand All @@ -88,6 +92,7 @@ func TestNewConfig(t *testing.T) {
"max-scale-up-rate": "1.0",
"container-concurrency-target-percentage": "0.5",
"container-concurrency-target-default": "10.0",
"target-burst-capacity": "12345",
"stable-window": "5m",
"panic-window": "10s",
"tick-interval": "2s",
Expand All @@ -98,6 +103,7 @@ func TestNewConfig(t *testing.T) {
EnableScaleToZero: true,
ContainerConcurrencyTargetFraction: 0.5,
ContainerConcurrencyTargetDefault: 10.0,
TargetBurstCapacity: 12345,
MaxScaleUpRate: 1.0,
StableWindow: 5 * time.Minute,
PanicWindow: 10 * time.Second,
Expand All @@ -113,6 +119,7 @@ func TestNewConfig(t *testing.T) {
"max-scale-up-rate": "1.0",
"container-concurrency-target-percentage": "0.5",
"container-concurrency-target-default": "10.0",
"target-burst-capacity": "1",
"stable-window": "5m",
"panic-window": "10s",
"tick-interval": "2s",
Expand All @@ -123,6 +130,7 @@ func TestNewConfig(t *testing.T) {
EnableScaleToZero: true,
ContainerConcurrencyTargetFraction: 0.5,
ContainerConcurrencyTargetDefault: 10.0,
TargetBurstCapacity: 1,
MaxScaleUpRate: 1.0,
StableWindow: 5 * time.Minute,
PanicWindow: 10 * time.Second,
Expand Down Expand Up @@ -206,6 +214,20 @@ func TestNewConfig(t *testing.T) {
"panic-threshold-percentage": "200",
},
wantErr: true,
}, {
name: "invalid target burst capacity",
input: map[string]string{
"max-scale-up-rate": "1.0",
"container-concurrency-target-percentage": "80",
"container-concurrency-target-default": "10.0",
"target-burst-capacity": "-1",
"stable-window": "3s",
"panic-window": "10s",
"tick-interval": "2s",
"panic-window-percentage": "10",
"panic-threshold-percentage": "200",
},
wantErr: true,
}, {
name: "invalid target %, too small",
input: map[string]string{
Expand Down