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

    Phaedrus

    Yes that's bad. Hopefully the jvm is smart enough not to listen to you. I'd take out the thread argument entirely.
     
  2. Offline

    mrciku

    Hmm, I'm gonna monitor for the next 2 days until Monday.
     
  3. Offline

    spowney

    OK I have a unique situation.

    Server specs
    i7 920 Quad 4 x 2.67 Ghz (HT)
    24gb ram
    ram disk for all worlds

    I currently run some unique plugins on a pvp deathmatch server with randomly loaded maps one after another.

    The key points - constant world loading / unloading (every 15 mins load a new world)
    Small worlds, Maximum 36 chunks loaded at any one time ever.
    Up to 60 players on those 36 chunks at the same time.

    I currently just use the default flags from the wiki and jre6 but I will upgrade to jre7 later.

    Any advise?
     
  4. Offline

    adamjon858

  5. Offline

    Phaedrus

    You can try this: http://forums.bukkit.org/threads/ho...24gb-dedicated-server.3967/page-2#post-184208
    Maybe. I noticed a difference going from 8 to 16. My usage sometimes peaks around 9 gigs when the server is busy. But I also have a few extra things running like mysql, Web server, map renders and backups.

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

    GmK

    While I see the same result (also running on 16gig and an i7) - the TPS does drop substantially with more players. Unfortunately.
     
  7. Offline

    Phaedrus

    An unfortunate consequence of a game designed around 8 player coop.
     
  8. Offline

    chiisana

    First of all, thanks to Phaedrus for figuring out the details of all those command line parameters, it really helped me to get started... For the most part, the server doesn't even make any noise -- less than 10% CPU usage on one core. But if I abuse it with WorldEdit, TNT and other annoyances, I get the occasional cannot keep up message. I'm wondering if there is anything else I can do to further optimize this setup I have.

    System Specs:
    Code:
    2x Intel(R) Xeon(R) CPU E5440 @ 2.83GHz (8 cores)
    8GB RAM
    Debian GNU/Linux 6.0.3 (squeeze); 2.6.32-5-amd64 (SMP) x86_64
    Sun-Java6-JDK & Sun-Java6-JRE
    I haven't cut away the ram to make my tmpfs for the server binaries, world, and plugin yet. Think I will be doing that later this week, after I get some observations on my server's actual needs (also hosting a few websites and SVN repositories on there). In the mean time, here are my server usage status:
    Code:
    $ free -m
                 total       used       free     shared    buffers     cached
    Mem:          8005       3301       4704          0        154       1937
    -/+ buffers/cache:       1209       6796
    Swap:         7742          0       7742
    
    $ df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda1             223G  2.8G  209G   2% /
    tmpfs                 4.0G     0  4.0G   0% /lib/init/rw
    udev                  4.0G  124K  4.0G   1% /dev
    tmpfs                 4.0G     0  4.0G   0% /dev/shm
    
    $ sysctl -p
    kernel.shmmax = 8589934592
    
    ...and my launch script:
    Code:
    #! /bin/bash
    # Configuration Variables
    server_jar="craftbukkit-1.9-pre5-R1-b20.jar"
    
    # Launch server
    java \
            -d64 \
            -Xmn512M -Xms1G -Xmx2G \
            -XX:PermSize=128m -XX:MaxPermSize=256m \
            -XX:NewRatio=3 -XX:+UseThreadPriorities \
            -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=1 -XX:SoftRefLRUPolicyMSPerMB=2048 \
            -XX:CMSInitiatingOccupancyFraction=90 \
            -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled \
            -XX:MaxGCPauseMillis=50 -XX:ParallelGCThreads=4 \
            -XX:+UseAdaptiveSizePolicy -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking \
            -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=15 \
            -Xnoclassgc -oss4M -ss4M -XX:UseSSE=4 -XX:+UseLargePages \
            -XX:+UseStringCache -XX:+UseCompressedStrings \
            -XX:+UseCompressedOops -XX:+OptimizeStringConcat \
            -XX:+UseFastAccessorMethods -XX:+AggressiveOpts \
            -cp $server_jar \
            -jar $server_jar \
            nogui
    Is there anything else that I should do to further fine tune this?
     
  9. Offline

    Phaedrus

    Remove Xnoclassgc. Apparently bukkit makes use of this and disabling it may lead to lost ram. Other than that it looks good. Ram disk might help a bit. MySQL may help if you have any database heavy programs.
     
  10. Do the launch arguments really work? Just we are sceptical. We have heavy lags on our server. We installed NoLagg but it doesn't help really. RAMDisk? We don't know whether these things will reduce lags together.

    We don't have plugins like LogBlock, but Jobs + MobArena. (Jobs: for every placing/breaking of blocks/killing mobs / crafting items player get or lose money). Is that the reason of lags? But iConomy, Jobs, xAuth and MyHome are working with MySQL.
    (Our Jobs config has 4k+ lines. Maybe it's the problem?)

    Our hardware ISN'T bad: 16x Core Intel Xeon, SSD, 24 Gb DDR3, 1000 Mb/s network.
    Our launch parameters (as far I know my main admin didn't experement with them):
    Code:
    /usr/bin/java -server -d64 -Xincgc -Xmx12g -Xms12g -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ParallelGCThreads=8 -Dfile.encoding=cp1251 -jar craftbukkit-0.0.1-SNAPSHOT.jar nogui
    Aren't 12gigs of allocated memory enough for 30-50 players? Sometimes there're baaad lags already with 30 on. (up to 19000+ms CommandBook's /debug clock)

    There are no dynmap('s) or LogBlock, the only plugin that could be pretty heavy is Anti Xray:
    http://forums.bukkit.org/threads/sec-ore-to-client-obfuscation-v1-7-1-1-anti-x-ray-xray-1337.26043/

    So why in the hell we have these terrible lags? Will these launch parameters increase our TPS? How people have servers with 100+ online without lags and more heavy plugins installed? idk what I have to do to reduce lags... You guys, you're my last hope. Say which methods will help us! We have MORE THAN ENOUGH memory, there're always 9+gigs of allocated memory free! But we get lags...
     
  11. Offline

    Phaedrus

    Try reading this for a better understanding:

    http://forums.bukkit.org/threads/ho...24gb-dedicated-server.3967/page-2#post-184208

    Specifically you'll want these:

    Code:
    -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseNUMA -XX:+CMSParallelRemarkEnabled -XX:MaxGCPauseMillis=50 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:UseSSE=3 -XX:+UseLargePages -XX:+UseFastAccessorMethods -XX:+UseStringCache -XX:+UseCompressedStrings -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts
    And don't use these:
    Code:
    -server -d64 -Xincgc -XX:ParallelGCThreads=8
    
    To find out if Jobs is lagging you, try removing jobs.
     
  12. @Phaedrus
    "-XX: ParallelGCThreads=8" won't Java try to use ALL 16 cores?
    and why shouldn't we force using of 64 bit components of java?

    Thanks for answer.
     
  13. Offline

    Phaedrus

    Server and d64 are redundant and already implied if you have 64 bit java installed. And if you have a heap over 2 gigs, you do.
     
  14. @Phaedrus
    But what about cores? I think it's "must-have" for us. Minecraft server isn't (won't be) the only server on the machine.
     
  15. Offline

    Phaedrus

    Java isn't a glut. It has internal mechanisms to determine how many cores to use depending on the work load. You are likely forcing it to use too many cores when it doesn't need them and not enough when it does.

    Switching from xincgc will be the biggest win.

    Just try it and see.
     
  16. "win" I like this word ^^
    Thanks, will force my main admin to try it out tomorrow.
     
  17. Offline

    Revenger

    Hope its ok I post in this thread seeing its a consolidated optmise thread it seems,

    We have a dedicated server on a:

    Intel Core 2 Quad Processor Q9550 2.83GHz 1333MHz 12MB LGA775 CPU 8gb DDR2 775

    We are getting cant keep up messages like crazy and 1 core is maxed with 5-8 players on.

    We went to a ramdisk on the map files to try to solve it but no luck.

    Our startup script we have just replaced to:

    Code:
    # Number of CPUs/cores to use
    CPU_COUNT=4
    # Initial memory usage
    INITMEM="4096M"
    # Maximum amount of memory to use
    MAXMEM="6144M"
    # Remember: give the ramdisk enough space, subtract from the total amount
    # of RAM available the size of your map and the RAM-consumption of your base system.
    INVOCATION="java -Xmx$MAXMEM -Xms$INITMEM -jar $SERVICE nogui"
    We do however run allot of plugins and going to test without hawkeye/logblock sometime.

    Code:
    01:36:04 [INFO] Plugins: Netstats, rTriggers, Spout, WorldGuard, GriefAlertR, NoLaggChunks, iConomy, CommandHelper, MCDocs, PermissionsEx, NoCheat, Permissions, SheepFeed, Admin GUI, AdminChat, WorldEdit, CFBanner, SimpleSignEdit, Modifyworld, BorderGuard, MCSL, SpoutEssentials, Lockette, Multiverse-Core, LogBlockQuestioner, SpamHammer, IWarnYou, Essentials, Warpz0r, BukkitSpeak, AutoRepair, Multiverse-Portals, EssentialsChat, LogBlock, EssentialsGeoIP, NoLagg, PluginControl, PrivateWarp, BukkitInventoryTools, MapMarkers, DeathTpPlus, DeathControl, Register, MobBounty, MyHome, properTime, VanishNoPacket, PluginControl, HawkEye
    its just soo annoying when back last year on hey0 this system could run up to 30 players now struggling with 5-8.

    We have even contacted the hosting company to see what a upgrade to the server would cost us on a monthly basis.
     
  18. Offline

    Phaedrus

    Have you tried adding the arguments I posted here?

    http://forums.bukkit.org/threads/ho...24gb-dedicated-server.3967/page-2#post-184208

    They would go after java in your INVOCATION line.
     
  19. @Revenger
    My local PC (i5 2400 4x@3GHz, 1GB allocated) hold up to 6 players without lags (the only barrier for me was my internet connection).
    So there're problems with server's software. You got bad hosting, I guess. But maybe their connection is bad too :D
     
  20. Offline

    Revenger

    Don't know about bad hosting we are with WOWRACK in the US and from what I read they seem reasonable.
     
  21. Offline

    Nathan C

    Hey,
    a couple of questions:

    Disabling HT doesn't help right?
    XMs flag is pointless now?

    Is this the correct flags for my server?
    Code:
    INVOCATION="java -Xmx12G -XX:PermSize=128m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=55 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=15 -Xnoclassgc -XX:UseSSE=3 -XX:+UseFastAccessorMethods -XX:+UseStringCache -XX:+UseCompressedStrings -XX:+OptimizeStringConcat -XX:+AggressiveOpts -jar $SERVICE"
    
    Code:
    Core i3 Sandy Bridge @ 3.1 Ghz (2 cores) HT on, so 4 threads.
    16 GB DDR3 Total:
       12 GB for server use
       1 GB for RAMdisk
       2.5 GB for OS and MySQL server
    1 x Sata III 7200 RPM
    Only one minecraft server going to be ran off this thing.
    Before I was only using barely any flags, but ever since I tried this it seems to be smoother with block places in creative mode.......maybe I am imagining it though.

    Thanks in advance,
    Nate
     
  22. Offline

    Phaedrus

    Hyperthreading is a good thing. It's not like the bad old P4 days.
    xms sets the starting heap size. Might as well just let Java decide what it needs and let it grow it up as needed. xmx should be below your physical ram limit by enough to allow the rest of the system enough ram for normal operation. usually 2-3 gigs.
    Looks good, except you should remove these:
    Code:
     -XX:ParallelGCThreads=2 -Xnoclassgc 
    Let Java decide how many threads to use. It will know best and change accordingly. and Noclassgc may be bad for bukkit and the devs have recommended not using that flag.
    and add this
    Code:
     -XX:+UseNUMA -XX:+UseLargePages 
    Allows the use of modern OS features to improve performance.
     
  23. Offline

    maxrate.pl

    Hi all

    This is my first post i guess, so I welcome all of You nicely :)

    I have following problem:

    My dedicated server:

    CPU: 2 x Intel Xeon - E5504 2 x 4 x 2,0 GHz (8 cores)
    RAM: 32 GB DDR3-RAM
    HD: 4 x 1.000 GB SATA II
    RAID - Areca 1210
    LAN: 1.000 MBit
    System: Linux Suse x64

    Iam running 50 slot server with following command line:


    bukkit version:

    [INFO] This server is running Craftbukkit version git-Bukkit-1.8.1-R4-77-ge86a355-b1550jnks (MC: 1.0.1) (Implementing API version 1.0.0-R1-SNAPSHOT)

    java system version

    java version "1.6.0_26"
    Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
    Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

    plugins on the server:

    AutoMessage.jar
    Minequery.jar
    LWC.jar
    PlugMan.jar
    WorldEdit.jar

    I have no errors in console.

    My server uses to much ram and cpu during.

    I've have already optimized my command line but it won't help.

    Empty Server:

    [​IMG]

    With one person:

    [​IMG]

    With 10 persons:

    [​IMG]

    With 18 persons

    [​IMG]

    My problem is following:

    Server uses to much RAM and CPU, i would like to optimize this, and have no idea what to do more.
    I would be appreciate to get some help in this matter. I've seen many posts on this forum with similar problems and users which have well knowledge to solve my problem.


    22 person on the server:

    [INFO] Maximum memory: 3 180 MB
    [INFO] Allocated memory: 1 257 MB
    [INFO] Free memory: 582 MB
    [INFO] World "Main": 3838chunks,2270entities
    [INFO] Nether "Main_nether": 108chunks,2entities
    [INFO] World "Main_the_end": 625chunks,19entities

    when on the server are about 30 people CPU rises to 150% or more, and I mem also.
     
  24. Offline

    Phaedrus

    Your command line is a bit of a disaster.

    Try the one detailed in this post
    http://forums.bukkit.org/threads/ho...24gb-dedicated-server.3967/page-2#post-184208
     
  25. Offline

    maxrate.pl

    I have this error in the console now:

    Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 1)

    Server after 2o persons is still overloaded, nothing has been changed:

    my command line is now as follow:

     
  26. Offline

    Phaedrus

    Try removing use large pages. It requires that your Linux district support it and have it enabled as well as the right user privs.
    That can be an excercise in your Linux guru training.
     
  27. Offline

    Zlasher

    Hello fellow minecrafters!

    Me and some friends have a server running Ubuntu server x64.
    Java:
    Code:
    java version "1.6.0_26"
    
    Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
    
    Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
    Hardware:
    cat /proc/cpuinfo:
    Code:
    processor       : 0
    vendor_id       : GenuineIntel
    cpu family      : 15
    model           : 4
    model name      : Intel(R) Pentium(R) D CPU 3.20GHz
    stepping        : 4
    cpu MHz         : 2803.000
    cache size      : 1024 KB
    physical id     : 0
    siblings        : 2
    core id         : 0
    cpu cores       : 2
    apicid          : 0
    initial apicid  : 0
    fpu             : yes
    fpu_exception   : yes
    cpuid level     : 5
    wp              : yes
    flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc pebs bts nopl pni dtes64 monitor ds_cpl est cid cx16 xtpr
    bogomips        : 6400.28
    clflush size    : 64
    cache_alignment : 128
    address sizes   : 36 bits physical, 48 bits virtual
    power management:
    
    processor       : 1
    vendor_id       : GenuineIntel
    cpu family      : 15
    model           : 4
    model name      : Intel(R) Pentium(R) D CPU 3.20GHz
    stepping        : 4
    cpu MHz         : 2803.000
    cache size      : 1024 KB
    physical id     : 0
    siblings        : 2
    core id         : 1
    cpu cores       : 2
    apicid          : 1
    initial apicid  : 1
    fpu             : yes
    fpu_exception   : yes
    cpuid level     : 5
    wp              : yes
    flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc pebs bts nopl pni dtes64 monitor ds_cpl est cid cx16 xtpr
    bogomips        : 6400.15
    clflush size    : 64
    cache_alignment : 128
    address sizes   : 36 bits physical, 48 bits virtual
    power management:
    And 4GB ram
    and we're considering to upgrade to 8GB and to an Intel E6300, worth it?

    What optimizations can we make? Change to OpenJDK7?
    Which flags would you recommend us to use?

    Best regards,
    a fellow minecraft server admin.
     
  28. Offline

    Phaedrus

    Try the one I detail here: http://forums.bukkit.org/threads/ho...24gb-dedicated-server.3967/page-2#post-184208
     
  29. Offline

    JohnEBH

    What flags should I remove if I'm using Java 7? Or would it matter if I left it as is?
     
  30. Offline

    Phaedrus

    You can leave it as is.
     
Thread Status:
Not open for further replies.

Share This Page