Skip to content

Commit 72a6f13

Browse files
committed
doc
1 parent 4285506 commit 72a6f13

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lightning_app/components/auto_scaler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,17 +370,17 @@ class AutoScaler(LightningFlow):
370370
# Example 2: Customizing the scaling logic
371371
class MyAutoScaler(L.app.components.AutoScaler):
372372
def scale(self, replicas: int, metrics: dict) -> int:
373-
max_requests_per_work = self.max_batch_size
374-
min_requests_per_work = 1
375373
pending_requests_per_running_or_pending_work = metrics["pending_requests"] / (
376374
replicas + metrics["pending_works"]
377375
)
378376
379377
# upscale
378+
max_requests_per_work = self.max_batch_size
380379
if pending_requests_per_running_or_pending_work >= max_requests_per_work:
381380
return replicas + 1
382381
383382
# downscale
383+
min_requests_per_work = max_requests_per_work * 0.25
384384
if pending_requests_per_running_or_pending_work < min_requests_per_work:
385385
return replicas - 1
386386

0 commit comments

Comments
 (0)