-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
docs: add autoscaling documentation and examples for mc-router integration #3826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
|
|
||
| # Autoscaling (sleep when idle) | ||
|
|
||
| Autoscaling (sometimes called *sleeping*, *scale to zero* or *wake on join*) is the pattern of stopping a Minecraft server when nobody is playing and starting it again when someone tries to connect with the intention of saving resources when the server is not in use (e.g., on a VPS with limited CPU/RAM or a home server). | ||
|
|
||
| ## mc-router | ||
|
|
||
| [mc-router](https://github.com/itzg/mc-router) is a Minecraft-aware router/multiplexer. | ||
|
|
||
| - Routes players by the hostname they connect with (useful for multiple servers behind one port) | ||
| - Can auto-start a backend container on join and stop it again after an idle timeout | ||
|
|
||
| Examples: | ||
|
|
||
| - See the mc-router section in [Examples](../examples.md#mc-router-with-auto-scale) | ||
|
|
||
| ## Lazymc | ||
|
|
||
| [Lazymc](https://github.com/timvisee/lazymc) can keep a server “asleep” until a player connects. With Docker it’s commonly used via [lazymc-docker-proxy](https://github.com/joesturge/lazymc-docker-proxy). | ||
|
|
||
| - Players connect to the proxy; the proxy starts/stops the server container | ||
| - Usually requires a static IP for the Minecraft container on a user-defined network | ||
|
|
||
| Example: | ||
|
|
||
| - See the Lazymc section in [Examples](../examples.md#lazymc-put-your-minecraft-server-to-rest-when-idle) | ||
|
|
||
| ## Lazytainer | ||
|
|
||
| [Lazytainer](https://github.com/vmorganp/Lazytainer) starts/stops containers based on network traffic. | ||
|
|
||
| - Uses packet thresholds + inactivity timeouts (not Minecraft hostname aware) | ||
| - Can be triggered by port scans/pings in noisy environments | ||
|
|
||
| Example: | ||
|
|
||
| - See the Lazytainer section in [Examples](../examples.md#lazytainer-stop-minecraft-container-based-on-traffic) | ||
|
|
||
|
|
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Source: https://github.com/itzg/mc-router/blob/main/examples/docker-autoscale/compose-minimal.yml | ||
| services: | ||
| router: | ||
| image: itzg/mc-router | ||
| environment: | ||
| IN_DOCKER: true | ||
| AUTO_SCALE_DOWN: true | ||
| AUTO_SCALE_UP: true | ||
| AUTO_SCALE_DOWN_AFTER: 2h | ||
| AUTO_SCALE_ASLEEP_MOTD: "Server is asleep. Join again to wake it up!" | ||
| ports: | ||
| - "25565:25565" | ||
| volumes: | ||
| - /var/run/docker.sock:/var/run/docker.sock:ro | ||
| vanilla: | ||
| image: itzg/minecraft-server | ||
| environment: | ||
| EULA: "TRUE" | ||
| labels: | ||
| mc-router.host: "vanilla.example.com" | ||
| paper: | ||
| image: itzg/minecraft-server | ||
| environment: | ||
| EULA: "TRUE" | ||
| TYPE: PAPER | ||
| labels: | ||
| mc-router.host: "paper.example.com" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Source: https://github.com/itzg/mc-router/blob/main/examples/docker-autoscale/compose.yml | ||
| # This is a verbose example with comments and explanations for configuring auto-scaling behavior | ||
| # for Docker backend servers. See compose-minimal.yml for a simple minimal example. | ||
| services: | ||
| router: | ||
| image: itzg/mc-router | ||
| environment: | ||
| IN_DOCKER: true | ||
| # Global auto-scaling settings for all docker-backend servers | ||
| # Settings can be overridden per-backend using labels | ||
| # as shown in the backend services below (except for AUTO_SCALE_DOWN_AFTER which is global only) | ||
| # Enable auto-scaling down after inactivity for all backends by default | ||
| AUTO_SCALE_DOWN: true | ||
| # Enable auto-scaling up after player join for all backends by default | ||
| AUTO_SCALE_UP: true | ||
| # Time of inactivity after which to scale down (default: 10m) - Global only setting | ||
| AUTO_SCALE_DOWN_AFTER: 2h | ||
| # MOTD to show when server is asleep (default: empty string - don't show MOTD, show server offline instead) | ||
| AUTO_SCALE_ASLEEP_MOTD: "Server is asleep. Join again to wake it up!" | ||
| ports: | ||
| - "25565:25565" | ||
| volumes: | ||
| - /var/run/docker.sock:/var/run/docker.sock:ro | ||
| vanilla: | ||
| image: itzg/minecraft-server | ||
| environment: | ||
| EULA: "TRUE" | ||
| labels: | ||
| # If global auto scaling settings are enabled, this backend will | ||
| # auto-scale without any additional auto-scale related configuration | ||
| mc-router.host: "vanilla.example.com" | ||
| fabric: | ||
| image: itzg/minecraft-server | ||
| environment: | ||
| EULA: "TRUE" | ||
| TYPE: FABRIC | ||
| labels: | ||
| mc-router.host: "fabric.example.com" | ||
| # Disable auto-scaling for this backend specifically | ||
| mc-router.auto-scale-up: false | ||
| mc-router.auto-scale-down: false | ||
| paper: | ||
| image: itzg/minecraft-server | ||
| environment: | ||
| EULA: "TRUE" | ||
| TYPE: PAPER | ||
| labels: | ||
| mc-router.host: "paper.example.com" | ||
| # Override asleep MOTD for this backend | ||
| mc-router.auto-scale-asleep-motd: "Paper is folded. Join to unfold!" |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Source links point to the external mc-router repository, but the examples are now part of this repository at
examples/mc-router-autoscale/. The links should point to the local examples to be consistent with other examples in this file (e.g., line 28 and 187). The Source link should point tohttps://github.com/itzg/docker-minecraft-server/blob/master/examples/mc-router-autoscale/compose-minimal.ymland the detailed example should point tohttps://github.com/itzg/docker-minecraft-server/blob/master/examples/mc-router-autoscale/compose.yml.