dstack icon indicating copy to clipboard operation
dstack copied to clipboard

[Feature] Provide a public API to scale services

Open peterschmidt85 opened this issue 1 year ago • 3 comments

Use-case: up-scale and down-scale services programmatically via an API

peterschmidt85 avatar Oct 02 '24 08:10 peterschmidt85

This is related to supporting updating the service replicas parameter in configuration without re-creating the service, that is, service configuration in-place updates.

r4victor avatar Oct 02 '24 09:10 r4victor

This is related to supporting updating the service replicas parameter in configuration without re-creating the service, that is, service configuration in-place updates.

Not sure. The issue is about providing an API that does what the server already does with auto-scaling of a running service based on the scaling configuration. Means we already have an internal API for this. We just need to make it public.

peterschmidt85 avatar Oct 02 '24 09:10 peterschmidt85

@peterschmidt85, We have a public API that allows specifying replicas. If we adjust it to support service configuration in-place updates, users could use it to modify replicas and implement custom autoscaling on top of it.

r4victor avatar Oct 02 '24 10:10 r4victor

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Nov 02 '24 01:11 github-actions[bot]

After #1958, users can change replicas and scaling parameters via dstack apply or Python/HTTP API:

import os
from dstack.api.server import APIClient

url = os.environ["DSTACK_URL"]
token = os.environ["DSTACK_TOKEN"]
project = os.environ["DSTACK_PROJECT"]

client = APIClient(base_url=url, token=token)

run = client.runs.get(project, "my-run")
new_run_spec = run.run_spec
new_run_spec.configuration.replicas = 3

plan = client.runs.get_plan(project, new_run_spec)
updated_run = client.runs.apply_plan(project, plan)

r4victor avatar Nov 05 '24 06:11 r4victor