feat: make the backend dial timeout configurable (--backend-dial-timeout)#570
Merged
itzg merged 1 commit intoJul 13, 2026
Merged
Conversation
…out) Follow-up to itzg#569: replace the fixed 2s backendDialTimeout constant with a --backend-dial-timeout flag (env BACKEND_DIAL_TIMEOUT), defaulting to the same 2s. Operators whose backends are reachable quickly (e.g. on-cluster Kubernetes Services) can lower it so the asleep MOTD / scale-up fallback fires sooner on a scaled-to-zero backend. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
wachirachoomsiri
added a commit
to CODECRAFTCLOUD/mc-router
that referenced
this pull request
Jul 12, 2026
wachirachoomsiri
added a commit
to CODECRAFTCLOUD/mc-router
that referenced
this pull request
Jul 13, 2026
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #569, which bounded the backend dial with a fixed 2s timeout so the auto-scale asleep MOTD is served promptly instead of hanging on the OS SYN-retry for a scaled-to-zero backend. This makes that bound configurable via a new
--backend-dial-timeoutflag (envBACKEND_DIAL_TIMEOUT), keeping the existing 2s as the default — so behavior is unchanged unless the flag is set.Why
The ideal value depends on how quickly backends are reachable:
100ms) to serve the asleep MOTD and trigger scale-up almost instantly on a scaled-to-zero Service.2s(or raise it) to avoid treating a reachable-but-slow backend as asleep.A single hard-coded constant can't serve both. #569 deliberately chose a conservative 2s; this leaves that as the default while letting operators tune it. (We run mc-router at
100mson a Kubernetes Minecraft-hosting deployment where every backend is an on-cluster Service.)Changes
server/configs.go— addBackendDialTimeout time.Duration(default:"2s") toConfig.server/connector.go— replace thebackendDialTimeoutconstant with a per-Connectorfield (defaultdefaultBackendDialTimeout= 2s) plus aUseBackendDialTimeout()setter, matching the existingUseAsleepMOTD/UseClientFilterstyle; the dial infindAndConnectBackendreads the field.server/server.go— wireconfig.BackendDialTimeoutinto the connector.README.md— document the new flag in the Usage list.Testing
go vet ./...andgo test ./server/... ./mcproto/...pass.defaultBackendDialTimeout).--helplists-backend-dial-timeout duration … (default 2s).