How can I optimize Java on my server?

Discussion in 'Bukkit Help' started by odielag, Feb 10, 2011.

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

    ShaDooM

    Oh... in irc someone told me to use java7 ^^ So java6 with proper gcs and settings would be better?
     
  2. Offline

    Phaedrus

    Probably. It'll be more likely to work consistently.
     
  3. Offline

    Rabus

    I'm using Java7 and can say that it runs surely faster...

    But there's one problem - after more people got in, I've got some small lags...
    100/100 connection speed, 8gb of ram still free, and every server got 3gb for 40 players...
     
  4. Offline

    Rabus

    It's getting worse and worse - today I started getting "can't keep up" message every 10 seconds..
     
  5. Offline

    Phaedrus

    That's a lot of servers. You need to recognize that. I think you're having some very unrealistic performance expectations considering how many servers you are trying to run.

    Are you using a ram disk? If not you are probably thrashing your disk.
    How many GC threads are you giving each server process? Try reducing it.
     
  6. Offline

    Rabus

    The problem is, everything went smooth for like 1 month?

    Even with online players on each server 55/40/35/15/5/3 it was all okay.
     
  7. Offline

    Phaedrus

    Are you using a ram disk? If not you are probably thrashing your disk.
    How many GC threads are you giving each server process? Try reducing it.

    The more people play, the more they explore and spread out. This increases the size of the world and due to the way the multiplayer cache works, may mean more world data is being loaded to ram and saved back to disk and sent out to your players.

    Was performance better before the 1.6 update?

    What mods do you run?

    Are you using MySQL?

    you're really not giving me any information to work with here, you're just complaining a lot. So either provide more info, or I will stop responding.
     
  8. Offline

    Rabus

    Sorry, I haven't sleep for a while so propably that's why I'm just complaining :)

    I'm using the command you provided me with, so I'm propably using 128/256 ramdisk. GC threads = 3 for each server.

    Mods:
    AutoSave
    BigBrother
    Border Guard
    Command Signs
    Controller Block
    CraftBukkitUpToDate
    DelayedStop
    Essentials
    Falsebook
    FakePermissions
    GroupManager
    iConomy
    iConomyChestShop
    LWC
    RealAdminTools
    SignColours0.3
    Spyer
    WorldEdit
    WorldGuard
    (other servers aren't so overloaded with plugins, just the main one)

    I'm not using MySQL

    I've downloaded the map today and.. It's 5000x5000! Propably will make it smaller tommorow.
     
  9. Offline

    Phaedrus

    1 - try reducing the number of GC threads to 2 for each server and reduce the pause time to 50ms
    2 - start using mysql. you have a lot of plugins that could be using it like iconomy, lwc, and big brother
    3 - try to stop using craftbukkituptodate. I noticed that whenever it would do a query for updates the server would basically hang.
    4 - essentials can be pretty terrible at times. see if you can move away from it to seperate plugins if possible
    5 - do you have all your server files on the ram disk as well, or just the world data? try moving everything onto a ramdisk.
     
  10. Offline

    Rabus

    Huh, I tought that command makes me a ramdisk and just do everything for me..

    Can I have some tutorial about that? :D
     
  11. Offline

    Phaedrus

    huh?
     
  12. Offline

    Rabus

    All I've done was setting this, i tought it was the ramdisk.. :
    -XX:permSize=128m -XX:MaxPermSize=256m

    Also - should I change this one to 2:
    -XX:UseSSE=3
    ?
     
  13. Offline

    Phaedrus

    no, not even close

    A ramdisk is a portion of your physical ram that is partitioned off and used as if it were a hard drive. It appears to the operating system to be just another disk. The benefit is that you have incredibly low response times and fast reads and writes. When you put all your server files and world data on a ram disk, it greatly reduces the I/O bottleneck you might see when using a much slower traditional hard drive. The downside is that it is volatile, meaning when the power goes out, the data is lost. This means very frequent backups and proper configuration are key. Get a UPS and setup incremental backups every 15 minutes.


    You're going to need to address the fundamental design of your server if you want to improve performance. Simply changing the garbage collection flags isn't going to fix your problems.

    Here is what I suggest you do.

    1. create a seperate thread in the help forum to seek guidance. Your problem goes beyond the scope of this thread and you will get more views if you start your own thread.
    2. you'll need to re evaluate having multiple servers running on the same hardware. ask yourself if a much simpler setup could achieve the same thing using multi-world and permissions. The overhead of running multiple instances may be a limiting factor.
    3. figure out how to configure a ramdisk.
    4. figure out how to configure MySQL.
     
  14. Offline

    Rabus

    I bet the problem isn't the map or the mysql - I've got 0 online and still can't keep up message... And my proc is at 100% all the time..
     
  15. Offline

    Kainzo

    I think I may try disabling hyperthreading - it may be hurting performance more than helping - thoughts?
    @Phaedrus
     
  16. Offline

    Phaedrus

    It's worth testing, but lowering the number of GC threads would make more sense.

    I think we're at a point where it's going to take some serious optimizations on Notches part to get better performance.
     
  17. Offline

    JohnTheRipper

    Any tips for a server using a 2.66GHZ Core2Quad Q9400, 8GB RAM, 500GB (7200RPM) HDD, CentOS 5.6 64-bit and Java 1.6.0_20 (64 bit)?

    Using CB 953 (although I am considering updating to a newer build).

    Runtime args:
    Code:
    java -Xms6G -Xmx6G -Djline.terminal=jline.UnsupportedTerminal -XX:ParallelGCThreads=4 -server -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:+AggressiveOpts -XX:+CMSParallelRemarkEnabled -XX:+DisableExplicitGC -XX:MaxGCPauseMillis=500 -XX:SurvivorRatio=16 -XX:TargetSurvivorRatio=90 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -Xnoclassgc -XX:UseSSE=3 -XX:PermSize=128m -XX:LargePageSizeInBytes=4m -jar /servers/minecraft/craftbukkit.jar nogui
    Plugins: MagicCarpet, rTriggers, SignColours, WorldEdit, Towny, FalseBook (all modules except for the chat one), LWC, BorderGuard, iConomy, WorldGuard, Minequery, CommandBook (1.5.3 DEV version), Stargates, iAuction, HeroChat, Permissions (3.1.6), PluginControl (for PrivateWarp), HeadBlocks, VanishNoPickup, RemoteToolkitPlugin (for the wrapper I use), ChestShops (beta version), PrivateWarp, NoCheat, LogBlock.

    I'm interested in what kind of tweaks I might want to do, and also my CPU usage is very high recently, so I'm wondering if one of those plugins or runtime args might be causing it. Are those good runtime args, or is there something I don't need?

    Thanks!
     
  18. Offline

    Phaedrus

    Same CPU and RAM I used to run with.

    Remove this: -XX:LargePageSizeInBytes=4m and reduce MaxGCPauseMillis=500 to 50

    Are you using MySQL yet?
     
  19. Offline

    JohnTheRipper

    Thanks for the info, I'll adjust that soon!

    I use MySQL only for LogBlock, I don't use it for iConomy (I thought of using it, but it's kind of too late now, seeing as I already have everything in a H2 DB).

    Right now, I am waiting for a new Bukkit build to come out, as the current RB has been giving me major memory leaks (80% usage after 5 hours online, with only 10-20 players on(!)).

    I plan on using a RAMdisk once I get Bukkit sorted out better and more players online, but for now I'm sticking with the HDD until I start seeing enough load/players to justify me setting one up.

    The CPU is a little overloaded after restarts, using ~160% for up to 10 minutes, before settling in at ~75% with ~15 players online (NoCheat is part of the problem).
     
  20. Offline

    Phaedrus

    You can migrate the iconomy database from H2 to MySQL. there are instructions on the iconomy wiki

    I use Remote Tool Kit to schedule server restarts every 3 hours to clear ram leaks. It's not really a big deal.

    Ram disk is very easy to setup. just be sure you have good frequent scheduled backups and a UPS
     
  21. Offline

    JohnTheRipper

    Hmm, I'll take a look at that...

    I also use the RKIT (which I've been using since the first hMod release), and i restart every 6 hours, but I might decrease the time for a short while (as I've taken to SSHing into the box every few hours to check how much memory is being consumed, and sometimes re-entering the console to quickly restart it when it's consuming all my RAM).

    I'll look into a RAM disk, but as I said, I most likely won't touch it until I start seeing 50+ players online (although if I see lag before that, I'll set it up).

    Alright, mind giving me some quick help here? I successfully managed to dump the data, but importing the data into my new MySQL DB fails with the error:

    Looking at the file in vim, here's the start of it:

    Code:
    CREATE USER IF NOT EXISTS SA SALT '44ce33b1fb37b15e' HASH '00c8b693beade10140c2606d99284df64d349990812a8022f16a7e25510f7552' ADMIN;
    CREATE SEQUENCE PUBLIC.SYSTEM_SEQUENCE_5ADEF080_EC46_4EB0_BD58_C82EEBD55336 START WITH 430 BELONGS_TO_TABLE;
    CREATE CACHED TABLE PUBLIC.ICONOMY(
        ID INT DEFAULT (NEXT VALUE FOR PUBLIC.SYSTEM_SEQUENCE_5ADEF080_EC46_4EB0_BD58_C82EEBD55336) NOT NULL NULL_TO_DEFAULT SEQUENCE PUBLIC.SYSTEM_SEQUENCE_5ADEF080_EC46_4EB0_BD58_C82EEBD55336 SELECTIVITY 100,
        USERNAME VARCHAR(32) SELECTIVITY 100,
        BALANCE DECIMAL(64, 2) SELECTIVITY 28,
        HIDDEN BOOLEAN DEFAULT '0' SELECTIVITY 1
    );
    ALTER TABLE PUBLIC.ICONOMY ADD CONSTRAINT PUBLIC.CONSTRAINT_8 PRIMARY KEY(ID);
    -- 374 +/- SELECT COUNT(*) FROM PUBLIC.ICONOMY;
    INSERT INTO PUBLIC.ICONOMY(ID, USERNAME, BALANCE, HIDDEN) VALUES
    (1, 'ZippyDoozy', 146.00, FALSE),
    (2, 'battlekid', 262.00, FALSE),
    (DB dump continues, but I cut off the snippet there).
    So, what would I do to fix this? Any help?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  22. Offline

    Phaedrus

    Sorry, I'm not really familiar. I started with MySQL so didn't have to convert. Try posting in the iconomy thread.
     
  23. Offline

    JohnTheRipper

    Reposting, as my RAM usage has been leaking constantly. even with Bukkit #1000...

    It's getting bad enough that I'm restarting every 4 hours, and during that time with less than 20 players on the entire time it leaks to ~80% RAM usage.

    All that above is still mostly true, but the startup line is like so now:

    Code:
    java -Xms6G -Xmx6G -Djline.terminal=jline.UnsupportedTerminal -XX:ParallelGCThreads=4 -server -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:+AggressiveOpts -XX:+CMSParallelRemarkEnabled -XX:+DisableExplicitGC -XX:MaxGCPauseMillis=50 -XX:SurvivorRatio=16 -XX:TargetSurvivorRatio=90 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -Xnoclassgc -XX:UseSSE=3 -XX:PermSize=128m -jar /servers/minecraft/craftbukkit.jar nogui
    Any help? This much RAM leaking isn't working well, I have 8GB, it shouldn't be using most of it up after a few hours. I have a feeling something is wrong with the command-line args again, but I am not quite sure what...

    I was going to try the advice in that other optimization thread, but it was for Java 7, which I'm not planning on updating to just yet (unless you think it's worth it).

    Thanks!
     
  24. Offline

    Phaedrus

    I dunno what the big deal is really. I get up to about 6 gigs usage in the same time as you and it stays around 6 gigs. To me that's normal.
     
  25. Offline

    Zalastri

    To everyone trying to tinker so much with all this stuff, try this.

    -Xms3G -Xmx3G -XX:+UseParNewGC -XX:MaxGCPauseMillis=200

    Just those flags. Obviously replace the 3 with however many gigs of ram you'd like your java to use. This is for multi core servers only.

    With this setup my server will still slowly eat all its memory over the course of a day or two, but it will stop at like the last 100 mb and somehow never go over that limit.
     
  26. Offline

    JohnTheRipper

    It's going over 6GB for me, and I don't like having it chew up all the RAM-- it sometimes causes lag :\.

    Hmm, maybe... Personally, I might just try some advice someone told me and use only the bare minimum to start it, and not to bother with fancy GC options.
     
  27. Offline

    Jobsti

    Sooo. Installed Java7 x64 on Ubuntu x64, runs much better (e.g. dynmapfullrender, now 70% CPU instead of 100%).

    Any special or recommened Java-Startparameters for Java7 + AMD quadcore?

    My old parameters for RTK:
    Code:
    initial-heap-size=4096M
    maximum-heap-size=8192M
    extra-runtime-arguments=-Djline.terminal\=jline.UnsupportedTerminal,-server,-Xmn2G,-XX:+UseConcMarkSweepGC,-XX:+UseParNewGC,-XX:+DisableExplicitGC,-XX:MaxGCPauseMillis=500,-XX:SurvivorRatio=16,-XX:TargetSurvivorRatio=90
     
  28. Offline

    Phaedrus

    There really isn't much you need to do to tune the garbage collector since 7 uses a completely new collector that supplants the one I recommend for Java 6 (the concurrent mark sweep).

    http://download.oracle.com/javase/7/docs/technotes/guides/vm/G1.html
     
  29. Offline

    Massimo1993

    @Phaedrus

    hi excuse me but i didn't now what im need to put:

    i've a dedicate server with 2 core 2.60 ghz 4gb ram, OS= freebsd 64bit and openjdk 6
     
  30. Offline

    Phaedrus

    Add these to your launch arguments.

    Code:
    -Xmx3G -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:MaxGCPauseMillis=50 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -Xnoclassgc -XX:UseSSE=3
     
Thread Status:
Not open for further replies.

Share This Page