Skip to content

Commit

Permalink
Remove limit_by_label_key from rate-limiting and concurrency-limiting…
Browse files Browse the repository at this point in the history
… configurations
  • Loading branch information
hasit committed Jan 5, 2024
1 parent 4d3fd6a commit 3de6e40
Show file tree
Hide file tree
Showing 28 changed files with 54 additions and 73 deletions.
1 change: 0 additions & 1 deletion blueprints/concurrency-limiting/base/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ commonConfig {
max_concurrency: '__REQUIRED_FIELD__',
selectors: commonConfig.selectors_defaults,
parameters: {
limit_by_label_key: 'limit_by_label_key',
max_inflight_duration: '__REQUIRED_FIELD__',
},
request_parameters: {},
Expand Down
1 change: 0 additions & 1 deletion blueprints/concurrency-limiting/base/gen/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"parameters": {
"description": "Parameters.",
"default": {
"limit_by_label_key": "limit_by_label_key",
"max_inflight_duration": "__REQUIRED_FIELD__"
},
"type": "object",
Expand Down
1 change: 0 additions & 1 deletion blueprints/concurrency-limiting/base/gen/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ policy:
# Type: aperture.spec.v1.ConcurrencyLimiterParameters
# Required: True
parameters:
limit_by_label_key: "limit_by_label_key"
max_inflight_duration: __REQUIRED_FIELD__
# Request Parameters.
# Type: aperture.spec.v1.ConcurrencyLimiterRequestParameters
Expand Down
7 changes: 1 addition & 6 deletions blueprints/concurrency-scheduling/base/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ commonConfig {
max_concurrency: '__REQUIRED_FIELD__',
selectors: commonConfig.selectors_defaults,
concurrency_limiter: {
limit_by_label_key: 'limit_by_label_key',
max_inflight_duration: '__REQUIRED_FIELD__',
},
scheduler: {
tokens_label_key: 'tokens',
priority_label_key: 'priority',
workload_label_key: 'workload',
},
scheduler: {},
alerter: {
alert_name: 'Too many inflight requests',
},
Expand Down
7 changes: 1 addition & 6 deletions blueprints/concurrency-scheduling/base/gen/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"concurrency_limiter": {
"description": "Concurrency Limiter Parameters.",
"default": {
"limit_by_label_key": "limit_by_label_key",
"max_inflight_duration": "__REQUIRED_FIELD__"
},
"type": "object",
Expand All @@ -75,11 +74,7 @@
},
"scheduler": {
"description": "Scheduler configuration.",
"default": {
"priority_label_key": "priority",
"tokens_label_key": "tokens",
"workload_label_key": "workload"
},
"default": {},
"type": "object",
"$ref": "../../../gen/jsonschema/_definitions.json#/definitions/Scheduler"
},
Expand Down
6 changes: 1 addition & 5 deletions blueprints/concurrency-scheduling/base/gen/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@ policy:
# Type: aperture.spec.v1.ConcurrencyLimiterParameters
# Required: True
concurrency_limiter:
limit_by_label_key: "limit_by_label_key"
max_inflight_duration: __REQUIRED_FIELD__
# Max concurrency.
# Type: float64
# Required: True
max_concurrency: __REQUIRED_FIELD__
# Scheduler configuration.
# Type: aperture.spec.v1.Scheduler
scheduler:
priority_label_key: "priority"
tokens_label_key: "tokens"
workload_label_key: "workload"
scheduler: {}
# Flow selectors to match requests against.
# Type: []aperture.spec.v1.Selector
# Required: True
Expand Down
7 changes: 1 addition & 6 deletions blueprints/quota-scheduling/base/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ commonConfig {
fill_amount: '__REQUIRED_FIELD__',
selectors: commonConfig.selectors_defaults,
rate_limiter: {
limit_by_label_key: 'limit_key',
interval: '__REQUIRED_FIELD__',
},
scheduler: {
tokens_label_key: 'tokens',
priority_label_key: 'priority',
workload_label_key: 'workload',
},
scheduler: {},
alerter: {
alert_name: 'More than 90% of requests are being rate limited',
},
Expand Down
9 changes: 2 additions & 7 deletions blueprints/quota-scheduling/base/gen/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,14 @@
"rate_limiter": {
"description": "Rate Limiter Parameters.",
"default": {
"interval": "__REQUIRED_FIELD__",
"limit_by_label_key": "limit_key"
"interval": "__REQUIRED_FIELD__"
},
"type": "object",
"$ref": "../../../gen/jsonschema/_definitions.json#/definitions/RateLimiterParameters"
},
"scheduler": {
"description": "Scheduler configuration.",
"default": {
"priority_label_key": "priority",
"tokens_label_key": "tokens",
"workload_label_key": "workload"
},
"default": {},
"type": "object",
"$ref": "../../../gen/jsonschema/_definitions.json#/definitions/Scheduler"
},
Expand Down
6 changes: 1 addition & 5 deletions blueprints/quota-scheduling/base/gen/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@ policy:
# Required: True
rate_limiter:
interval: __REQUIRED_FIELD__
limit_by_label_key: "limit_key"
# Scheduler configuration.
# Type: aperture.spec.v1.Scheduler
scheduler:
priority_label_key: "priority"
tokens_label_key: "tokens"
workload_label_key: "workload"
scheduler: {}
# Flow selectors to match requests against.
# Type: []aperture.spec.v1.Selector
# Required: True
Expand Down
1 change: 0 additions & 1 deletion blueprints/rate-limiting/base/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ commonConfig {
fill_amount: '__REQUIRED_FIELD__',
selectors: commonConfig.selectors_defaults,
parameters: {
limit_by_label_key: 'limit_key',
interval: '__REQUIRED_FIELD__',
},
request_parameters: {},
Expand Down
3 changes: 1 addition & 2 deletions blueprints/rate-limiting/base/gen/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@
"parameters": {
"description": "Parameters.",
"default": {
"interval": "__REQUIRED_FIELD__",
"limit_by_label_key": "limit_key"
"interval": "__REQUIRED_FIELD__"
},
"type": "object",
"$ref": "../../../gen/jsonschema/_definitions.json#/definitions/RateLimiterParameters"
Expand Down
1 change: 0 additions & 1 deletion blueprints/rate-limiting/base/gen/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ policy:
# Required: True
parameters:
interval: __REQUIRED_FIELD__
limit_by_label_key: "limit_key"
# Request Parameters.
# Type: aperture.spec.v1.RateLimiterRequestParameters
request_parameters: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ spec:
num_sync: 4
limit_by_label_key: api_key
scheduler:
priority_label_key: priority
tokens_label_key: tokens
workload_label_key: workload
workloads:
- label_matcher:
match_labels:
Expand Down
1 change: 0 additions & 1 deletion docs/content/guides/assets/managing-quotas/policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ spec:
limit_by_label_key: user_id
scheduler:
priority_label_key: priority
tokens_label_key: tokens
workload_label_key: workload
selectors:
- control_point: quota-scheduling-feature
Expand Down
2 changes: 0 additions & 2 deletions docs/content/guides/assets/openai/policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ spec:
limit_by_label_key: api_key
scheduler:
priority_label_key: priority
tokens_label_key: tokens
workload_label_key: workload
selectors:
- control_point: openai
label_matcher:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ policy:
# Required: True
parameters:
interval: __REQUIRED_FIELD__
limit_by_label_key: "limit_key"
# Request Parameters.
# Type: aperture.spec.v1.RateLimiterRequestParameters
request_parameters: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ href={`https://github.com/fluxninja/aperture/tree/${aver}/blueprints/concurrency
description='Parameters.'
type='Object (aperture.spec.v1.ConcurrencyLimiterParameters)'
reference='../../configuration/spec#concurrency-limiter-parameters'
value='{"limit_by_label_key": "limit_by_label_key", "max_inflight_duration": "__REQUIRED_FIELD__"}'
value='{"max_inflight_duration": "__REQUIRED_FIELD__"}'
/>

<!-- vale on -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ href={`https://github.com/fluxninja/aperture/tree/${aver}/blueprints/concurrency
description='Concurrency Limiter Parameters.'
type='Object (aperture.spec.v1.ConcurrencyLimiterParameters)'
reference='../../configuration/spec#concurrency-limiter-parameters'
value='{"limit_by_label_key": "limit_by_label_key", "max_inflight_duration": "__REQUIRED_FIELD__"}'
value='{"max_inflight_duration": "__REQUIRED_FIELD__"}'
/>

<!-- vale on -->
Expand Down Expand Up @@ -135,7 +135,7 @@ href={`https://github.com/fluxninja/aperture/tree/${aver}/blueprints/concurrency
description='Scheduler configuration.'
type='Object (aperture.spec.v1.Scheduler)'
reference='../../configuration/spec#scheduler'
value='{"priority_label_key": "priority", "tokens_label_key": "tokens", "workload_label_key": "workload"}'
value='{}'
/>

<!-- vale on -->
Expand Down
4 changes: 2 additions & 2 deletions docs/content/reference/blueprints/quota-scheduling/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ href={`https://github.com/fluxninja/aperture/tree/${aver}/blueprints/quota-sched
description='Rate Limiter Parameters.'
type='Object (aperture.spec.v1.RateLimiterParameters)'
reference='../../configuration/spec#rate-limiter-parameters'
value='{"interval": "__REQUIRED_FIELD__", "limit_by_label_key": "limit_key"}'
value='{"interval": "__REQUIRED_FIELD__"}'
/>

<!-- vale on -->
Expand All @@ -149,7 +149,7 @@ href={`https://github.com/fluxninja/aperture/tree/${aver}/blueprints/quota-sched
description='Scheduler configuration.'
type='Object (aperture.spec.v1.Scheduler)'
reference='../../configuration/spec#scheduler'
value='{"priority_label_key": "priority", "tokens_label_key": "tokens", "workload_label_key": "workload"}'
value='{}'
/>

<!-- vale on -->
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/blueprints/rate-limiting/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ href={`https://github.com/fluxninja/aperture/tree/${aver}/blueprints/rate-limiti
description='Parameters.'
type='Object (aperture.spec.v1.RateLimiterParameters)'
reference='../../configuration/spec#rate-limiter-parameters'
value='{"interval": "__REQUIRED_FIELD__", "limit_by_label_key": "limit_key"}'
value='{"interval": "__REQUIRED_FIELD__"}'
/>

<!-- vale on -->
Expand Down
25 changes: 25 additions & 0 deletions pkg/scheduler/wfq.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,32 @@ func (pMetrics *preemptionMetrics) onQueueEntry(request *Request, qRequest *queu
// Update metrics for preemption and delay
// WARNING: Unsafe and should be called with scheduler lock.
func (pMetrics *preemptionMetrics) onQueueExit(request *Request, qRequest *queuedRequest, allowed bool) {
initMetrics := func(labels prometheus.Labels) error {
var err error
_, err = pMetrics.workloadPreemptedTokensSummary.GetMetricWith(labels)
if err != nil {
return fmt.Errorf("%w: failed to get workload_preempted_tokens summary", err)
}
_, err = pMetrics.workloadDelayedTokensSummary.GetMetricWith(labels)
if err != nil {
return fmt.Errorf("%w: failed to get workload_delayed_tokens summary", err)
}
_, err = pMetrics.workloadOnTimeCounter.GetMetricWith(labels)
if err != nil {
return fmt.Errorf("%w: failed to get workload_on_time_total counter", err)
}
return nil
}

publishSummary := func(summary *prometheus.SummaryVec, value float64) {
if summary == nil {
return
}
metricsLabels := appendWorkloadLabel(pMetrics.metricsLabels, request.FairnessLabel)
err := initMetrics(metricsLabels)
if err != nil {
log.Error().Err(err).Msg("Failed to initialize metrics")
}
observer, err := summary.GetMetricWith(metricsLabels)
if err != nil {
log.Error().Err(err).Msg("Failed to get workload preempted tokens summary")
Expand All @@ -546,6 +567,10 @@ func (pMetrics *preemptionMetrics) onQueueExit(request *Request, qRequest *queue
return
}
metricsLabels := appendWorkloadLabel(pMetrics.metricsLabels, request.FairnessLabel)
err := initMetrics(metricsLabels)
if err != nil {
log.Error().Err(err).Msg("Failed to initialize metrics")
}
counter, err := counterVec.GetMetricWith(metricsLabels)
if err != nil {
log.Error().Err(err).Msg("Failed to get workload on time counter")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ spec:
accept_percentage:
signal_name: ACCEPT_PERCENTAGE
scheduler:
priority_label_key: priority
tokens_label_key: tokens
workload_label_key: workload
workloads:
- label_matcher:
match_labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@ spec:
- flow_control:
concurrency_scheduler:
concurrency_limiter:
limit_by_label_key: limit_by_label_key
max_idle_time: 7200s
max_inflight_duration: 60s
in_ports:
max_concurrency:
constant_signal:
value: 10
value: 2
out_ports:
accept_percentage:
signal_name: ACCEPT_PERCENTAGE
scheduler:
denied_response_status_code: BadRequest
priority_label_key: priority
tokens_label_key: tokens
workload_label_key: userType
selectors:
- agent_group: default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ policy:
concurrency_limiter:
max_inflight_duration: 60s
max_idle_time: "7200s"
max_concurrency: 10
max_concurrency: 2
scheduler:
workload_label_key: "userType"
priority_label_key: "priority"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ spec:
num_sync: 4
limit_by_label_key: http.request.header.api_key
scheduler:
priority_label_key: priority
tokens_label_key: tokens
workload_label_key: workload
workloads:
- label_matcher:
match_labels:
Expand Down
2 changes: 1 addition & 1 deletion sdks/aperture-go/examples/manual/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect
github.com/fluxninja/aperture/api/v2 v2.0.0-20240101092959-235caef8dbad // indirect
github.com/fluxninja/aperture/api/v2 v2.0.0-20240104011105-0680993ed282 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
Expand Down
4 changes: 2 additions & 2 deletions sdks/aperture-go/examples/manual/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA=
github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE=
github.com/fluxninja/aperture/api/v2 v2.0.0-20240101092959-235caef8dbad h1:J4SgDerz6NPEARbKEXvR5nAjSN1DWJ2J3NnzJKM+JcU=
github.com/fluxninja/aperture/api/v2 v2.0.0-20240101092959-235caef8dbad/go.mod h1:KSjIteqXmGJl1WOxQeBF9/K6/0sMHfKsRl5VOQkxyNg=
github.com/fluxninja/aperture/api/v2 v2.0.0-20240104011105-0680993ed282 h1:3UK/8Z97YO2o6WutDRmKiWLeURT/x5+aFTBIIf/fh4Q=
github.com/fluxninja/aperture/api/v2 v2.0.0-20240104011105-0680993ed282/go.mod h1:KSjIteqXmGJl1WOxQeBF9/K6/0sMHfKsRl5VOQkxyNg=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
Expand Down
Loading

0 comments on commit 3de6e40

Please sign in to comment.