Dismiss Notice
Wynncraft, the Minecraft MMORPG. Play it now on your Minecraft client at (IP): play.wynncraft.com. No mods required! Click here for more info...

About Server Restarts

Discussion in 'Wynncraft' started by __Excel, Oct 30, 2020.

Thread Status:
Not open for further replies.
  1. __Excel

    __Excel i like cats VIP+

    Messages:
    596
    Likes Received:
    672
    Trophy Points:
    125
    Minecraft:
    I have seen or talked with a lot of people who would want server restarts to be either removed or have them occur less often. This thread just shows some of my thoughts on why server restarts exist, and why they should stay the way they are.

    Java has an interesting way of dealing with memory usage. Essentially, when a programmer creates an object, the server allocates space in the memory (RAM) for said object. The server will hold on to that object and get rid of it as soon as it deems in "inaccessible" by anything inside the program, since inaccessible=useless. Say the programmer makes a "Player" object, representing a player that has just logged in. As soon as the player logs out, minecraft (well actually bukkit too) will cut ties with that player object, and what is known as the garbage collector will get rid of it and deem that area in the memory as open for usage by other things (in simple words, it just deletes it). The garbage collector will just rid the system of all leftover bits of information that the programmer has left behind.
    (Side note: some programming languages require you to manually tell the system when it can throw things out the window, but java doesn't.)

    However, like most things, java garbage collection can't be perfect. Coders will often make mistakes, and leave permanent ties (or other things which i won't get into) to data which is no longer needed. This is called a memory leak. This means that the server has allocated space in the memory for data which isn't even being used, and won't be used in the future (or can't be used).

    These memory leaks can be fixed by:
    • Manually going over every possible memory leak and telling the garbage collector to toss it once wynncraft is done with it. This is an incredibly tedious task when you have a large (and maybe unorganized) codebase, and can require a lot of effort.
    • There are a bunch of small tricks to avoiding memory leaks in the first place, which I am not going to cover because in wynncraft's case, it would already be too late to implement them seeing as they already have a very large codebase. If you really want to know about them, you can read about how to avoid memory leaks here and some other cool stuff about memory leaks. If this was feasible, it still wouldn't fix all memory leaks, just prevent some of the easily avoided stuff.
    • Server restarts - where the server tosses basically everything it has stored and starts everything up again. This is by far the easiest solution. The amount of time between restart depends on two things:
    1. How much memory wynncraft has allocated to each shard (how much memory each server can work with).
    2. How quickly these memory leaks pile up. If it gets to a point where the server is running out of space because of leaks and it hasn't restarted yet, you are in trouble.
    Conclusion:
    • Removing restarts won't be possible. There will always be memory leaks, they will just vary in size and severity.
    • Making the amount of time between restarts would require one of two things:
    1. Allocating more memory to each shard - expensive
    2. Fixing as many memory leaks as possible - tedious and time consuming
    So I personally would prefer they worked on the upcoming updates instead of focusing on server restarts.


    (Small Note: I know a lot about this sort of stuff because I develop games myself. I just wanted to share what I think about server restarts because i understand why they do them, or at least i hope i do :D)
     
  2. TrapinchO

    TrapinchO retired observer of the wiki VIP+ Featured Wynncraftian

    Messages:
    4,662
    Likes Received:
    6,602
    Trophy Points:
    217
    Minecraft:
    Imo they should drop the update and them just improve the code for at least a month.

    Great thread!
    ________________________________
    For really simple-minded individuals: If the servers does not restart, they crash (or the whole server too). To fix it either pay more (really bad) or code better (hard and really slow)
     
    Last edited: Oct 31, 2020
    __Excel likes this.
  3. CarrotKing269

    CarrotKing269 Well-Known Adventurer

    Messages:
    64
    Likes Received:
    57
    Trophy Points:
    57
    Minecraft:
    i just got 10 times smarter reading that
     
    __Excel and penguinbnuuy like this.
  4. J_Lo777

    J_Lo777 Wynn Artist CHAMPION

    Messages:
    981
    Likes Received:
    575
    Trophy Points:
    97
    Guild:
    Minecraft:

    Don't you mean, if the servers don't restart, they crash? (because they would keep accumulating garbage data and run out of memory)
     
    TrapinchO, __Excel and hppeng like this.
  5. hppeng

    hppeng 0 intel is the correct amount of intel HERO

    Messages:
    1,243
    Likes Received:
    2,007
    Trophy Points:
    153
    Guild:
    Minecraft:
    ngl as a programmer this sounds like a bit like making excuses for bad code, I hope this isn't really the reason they have to restart every so often

    (that being said modded minecraft does seem to have this problem as well, might really just be bad code)


    Memory leaks can be indicative of some deeper issues, if you don't "code better" you end up with really broken stuff that is much more difficult to fix (technical debt fwiw)

    There are java memory profilers out there, I believe there's one built into java itself that you can use to track performance metrics and memory usage, might be worth looking into if this is actually a problem
     
    __Excel likes this.
  6. sjuka_legogubbar

    sjuka_legogubbar Well-Known Adventurer VIP+

    Messages:
    610
    Likes Received:
    226
    Trophy Points:
    64
    Minecraft:
    A nice workaround would be to, when the server has to restart, move all players and most the important (other) data such as bombs, totems and maybe mobs to a new server (that boots when the other restarts). This way it wouldnt be that noticable when servers restart, as it would simply be a flash(or like 30 sec for us with slow computers :( ) of ”loading new terrain”.

    I don’t see it as a big problem though, and new content should definitely come before changeing the restarts.
     
  7. __Excel

    __Excel i like cats VIP+

    Messages:
    596
    Likes Received:
    672
    Trophy Points:
    125
    Minecraft:
    This is still a big networking puzzle, it would require them to build some infrastructure to get the servers to sync. It still would be a possibility though.
    What I would propose instead, is just the server prevents players from joining it before it restarts (maybe like 30 minutes before or an hour) and then less players are affected by the restart.
    I think that with Minecraft it is very hard to make code which is efficient to that level, but because of how messy bukkit plugin interaction ends up being. If wynncraft was a stand-alone game, I would agree that they could have done better.
    And also, if bukkit coding is messy, forge is 100 times more messy, and that is why modded servers are so unstable with the more mods they have.
    Yeah I agree, though these deeper issues (in bukkit’s case) may not always come from things which the wynncraft programmers control.
    If they really wanted to fix this issue, this is where they would start. But for now I think they are okay with the way things work currently.
    ________________________________
    Oh also moving to a new server won’t just be a “flash” it will still do all the loading. The flash is when moving between worlds on the same server.
     
    hppeng likes this.
  8. TrapinchO

    TrapinchO retired observer of the wiki VIP+ Featured Wynncraftian

    Messages:
    4,662
    Likes Received:
    6,602
    Trophy Points:
    217
    Minecraft:
    I am stupid and forgot to put the "don't", thanks.
     
    J_Lo777 and __Excel like this.
Thread Status:
Not open for further replies.