File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
src/lightning_app/components Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -370,17 +370,17 @@ class AutoScaler(LightningFlow):
370
370
# Example 2: Customizing the scaling logic
371
371
class MyAutoScaler(L.app.components.AutoScaler):
372
372
def scale(self, replicas: int, metrics: dict) -> int:
373
- max_requests_per_work = self.max_batch_size
374
- min_requests_per_work = 1
375
373
pending_requests_per_running_or_pending_work = metrics["pending_requests"] / (
376
374
replicas + metrics["pending_works"]
377
375
)
378
376
379
377
# upscale
378
+ max_requests_per_work = self.max_batch_size
380
379
if pending_requests_per_running_or_pending_work >= max_requests_per_work:
381
380
return replicas + 1
382
381
383
382
# downscale
383
+ min_requests_per_work = max_requests_per_work * 0.25
384
384
if pending_requests_per_running_or_pending_work < min_requests_per_work:
385
385
return replicas - 1
386
386
You can’t perform that action at this time.
0 commit comments