Skip to content

Commit b9dedbe

Browse files
zroubalikshubhusion
authored andcommitted
add explanation fore eager scaling strategy (kedacore#1438)
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com> Signed-off-by: shubhusion <shubham27.sharma03@gmail.com>
1 parent 2a3835c commit b9dedbe

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

content/docs/2.15/reference/scaledjob-spec.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ scalingStrategy:
150150
strategy: "default" # Optional. Default: default. Which Scaling Strategy to use.
151151
```
152152

153-
Select a Scaling Strategy. Possible values are `default`, `custom`, or `accurate`. The default value is `default`.
153+
Select a Scaling Strategy. Possible values are `default`, `custom`, `accurate`, or `eager`. The default value is `default`.
154154

155155
> 💡 **NOTE:**
156156
>
@@ -221,6 +221,59 @@ if (maxScale + runningJobCount) > maxReplicaCount {
221221
```
222222
For more details, you can refer to [this PR](https://github.com/kedacore/keda/pull/1227).
223223

224+
**eager**
225+
When adopting the **default** strategy, you are likely to come into a subtle case where messages need to be consumed by spawning jobs but remain in the queue, even when there are available slots between `runningJobCount` and `maxReplicaCount`. The **eager** strategy comes to the rescue. It addresses this issue by utilizing all available slots up to the maxReplicaCount, ensuring that waiting messages are processed as quickly as possible.
226+
227+
For example, let's assume we configure a ScaledJob in a cluster as below:
228+
```yaml
229+
###
230+
# A job that runs for a minimum of 3 hours.
231+
###
232+
pollingInterval: 10 # Optional. Default: 30 seconds
233+
maxReplicaCount: 10 # Optional. Default: 100
234+
triggers:
235+
- type: rabbitmq
236+
metadata:
237+
queueName: woker_queue
238+
hostFromEnv: RABBITMQ_URL
239+
mode: QueueLength
240+
value: "1"
241+
```
242+
We send 3 messages to the Rabbitmq and wait longer enough than the `pollingInterval`, then send another 3.
243+
244+
With the `default` scaling strategy, we are supposed to see the metrics changes in the following table:
245+
246+
| | initial | incoming 3 messages | after poll | incoming 3 messages | after poll |
247+
|-------------|---------|---------------------|------------|---------------------|------------|
248+
| queueLength | 0 | 3 | 3 | 6 | 6 |
249+
| runningJobs | 0 | 0 | 3 | 3 | 3 |
250+
251+
252+
If we switch to `eager`, the result becomes:
253+
254+
| | initial | incoming 3 messages | after poll | incoming 3 messages | after poll |
255+
|-------------|---------|---------------------|------------|---------------------|------------|
256+
| queueLength | 0 | 3 | 3 | 6 | 6 |
257+
| runningJobs | 0 | 0 | 3 | 3 | 6 |
258+
259+
We can identify the difference in their final states.
260+
261+
262+
You may also refer to [this original issue](https://github.com/kedacore/keda/issues/5114) for more information.
263+
264+
---
265+
266+
```yaml
267+
scalingStrategy:
268+
multipleScalersCalculation : "max" # Optional. Default: max. Specifies how to calculate the target metrics (`queueLength` and `maxScale`) when multiple scalers are defined.
269+
```
270+
Select a behavior if you have multiple triggers. Possible values are `max`, `min`, `avg`, or `sum`. The default value is `max`.
271+
272+
* **max:** - Use metrics from the scaler that has the max number of `queueLength`. (default)
273+
* **min:** - Use metrics from the scaler that has the min number of `queueLength`.
274+
* **avg:** - Sum up all the active scalers metrics and divide by the number of active scalers.
275+
* **sum:** - Sum up all the active scalers metrics.
276+
224277

225278
### multipleScalersCalculation
226279

0 commit comments

Comments
 (0)