Skip to content

Add in-place update for gateway replicas#4014

Open
jvstme wants to merge 2 commits into
masterfrom
issue_3959_gateway_scaling
Open

Add in-place update for gateway replicas#4014
jvstme wants to merge 2 commits into
masterfrom
issue_3959_gateway_scaling

Conversation

@jvstme

@jvstme jvstme commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Support scaling gateways via in-place update of
the replicas configuration property. For now,
this feature is only intended for internal testing
and is hidden behind the GATEWAY_SCALING flag,
since it has limited applicability at the current
stage — without a state sync mechanism, newly
started gateway replicas are not aware of existing
services.

#3959

Support scaling gateways via in-place update of
the `replicas` configuration property. For now,
this feature is only intended for internal testing
and is hidden behind the `GATEWAY_SCALING` flag,
since it has limited applicability at the current
stage — without a state sync mechanism, newly
started gateway replicas are not aware of existing
services.
@jvstme jvstme requested a review from r4victor July 8, 2026 22:29
async with get_session_ctx() as session:
for gateway_compute_model in result.gateway_compute_models:
session.add(gateway_compute_model)
await _apply_replica_scaling(session, result.scale_result)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is an issue with _apply_replica_scaling() being called before lock_token guard. It can lead to a stale worker committing new replicas without updating the gateway. E.g. a stale submitted gateway can create replicas. Then, it will be re-processed with duplicate replicas committed again. All related db changes / side effects should be done after the lock_token guard.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a gateway replica never provisions (e.g. there is some cloud issue, backend availability, etc), the reconcile loop never terminates, re-creating replicas forever. We need some backoff logic and a limit. For fleets, we have _MAX_CONSOLIDATION_ATTEMPTS and _CONSOLIDATION_RETRY_DELAYS.

for num in itertools.count():
if num not in used_nums:
yield num
assert False, "unreachable"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itertools.count() is infinite. why assert False, "unreachable"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants