diff --git a/public/posts/index.html b/public/posts/index.html index 80cb3ba..740401b 100644 --- a/public/posts/index.html +++ b/public/posts/index.html @@ -11,6 +11,12 @@ "footer2 footer" ; grid-template-columns: 1fr 1fr; + max-width: 120ch; + } + + #content>.content { + text-align: justify; + text-justify: auto; } img { @@ -20,13 +26,15 @@ } img.enlarged { - position: absolute; + position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); height: 80%; - max-width: 80%; + max-width: 90%; + object-fit:contain; border-radius: 0px; + background: transparent; } #content>.footer { diff --git a/public/posts/minecraft-proxy.md b/public/posts/minecraft-proxy.md new file mode 100644 index 0000000..d272957 --- /dev/null +++ b/public/posts/minecraft-proxy.md @@ -0,0 +1,33 @@ +Minecraft Rust Async Networking Proxy CRIU +# Minecraft servers are HUNGRY +They hunger for your ram and your cpu. This makes it either expensive or laggy to try and host multiple servers at once. +This was something I encountered when my friend built a homeserver out of spare computer parts that was barely powerful enough to run a minecraft server. +The problem was that soon multiple people wanted a minecraft server hosted by him, including ourselves with modded experiences. + +It was a hassle to ssh into the server and start and stop the various servers depending on who wanted to play, +especially since a lot of people only played very rarily. + +I remembered that I'd seen [a project](https://github.com/gekware/minecraft-server-hibernation) that claimed to be able to hibernate a minecraft server if nobody was playing on it. +This worked by starting and stopping the server, leading to noticeable join delays when joining modded servers. + +Another nice-to-have was being able to join through a subdomain. After having messed around with nginx to help my friend set up various services like nextcloud +on subdomains we wanted to do the same for the minecraft servers. + +Being able to join the vanilla server through `vanilla.domain.com` and the modded through `modded.domain.com` would simply be really cool. + +# Minecraft Server Hibernation Proxy Manager Rs (Name WIP) + +I ended up writing [a Rust program](https://gitlab.com/SpoodyTheOne/minecraft-server-hibernation-proxy-rust) that could do this and more. It listens on the default minecraft server port of `25565` and parses any incoming data as minecraft packets. +If the data contains a url that matches `*.domain.com` then it uses the subdomain to look up a configured server, and if found redirects all future traffic to that port. + +![Image of a server displaying the startup message](/posts/minecraft-proxy/starting.png "A server that is waiting to be started") + +If the server is stopped or hibernating then the command to start it is automatically run. Likewise if all players leave a configurable countdown is started. +Once it reaches 0 the server is hibenated using CRIU, which writes the entire memory and all open file descriptors of the server program to disk. + +![Hibernating server](/posts/minecraft-proxy/hibernating.png "Hibernating server") + +This means that joining a hibernated server only takes a few seconds, and any server currently hibernating will only take up disk space. +It can also be restored even after system restarts, so it would be possible to halt systemd shutdowns until all servers are hibernated. + +Marq**WEE** diff --git a/public/posts/minecraft-proxy/hibernating.png b/public/posts/minecraft-proxy/hibernating.png new file mode 100644 index 0000000..32593ab Binary files /dev/null and b/public/posts/minecraft-proxy/hibernating.png differ diff --git a/public/posts/minecraft-proxy/starting.png b/public/posts/minecraft-proxy/starting.png new file mode 100644 index 0000000..7b4f507 Binary files /dev/null and b/public/posts/minecraft-proxy/starting.png differ