Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


OpenVZ Java QA
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

OpenVZ Java QA

concerto49concerto49 Member
edited November 2012 in Help

Hi, don't know if this is of any use or not, but I'd like to open to this to answer any questions around OpenVZ and answer any questions to do with Java.

Specifically as we know there are lots of myths around Java not working on OpenVZ, it's bloated etc.

If you have any Java performance questions in general, optimizing memory, OpenVZ & Java related, post them here and I'll try my best to answer it.

This is just a nice thing for the community :)

And FYI I do have extensive knowledge on the JVM and Java coding in general both academically and professional, especially to do with performance/optimization. It's my research area :)

«1

Comments

  • Java works fine for me on OVZ. And it's fast. Just consumes double the memory vs. KVM or XEN

  • @jcaleb said: Java works fine for me on OVZ. And it's fast. Just consumes double the memory vs. KVM or XEN

    VSwap or no VSwap and how much VSwap?

    The problem is Java maps a lot of things into virtual memory by default, e.g. heavily uses mmap and the like at a low level. It depends on the application. There are certain things to tune - stack size, native heap (yes it exists for things like native ByteBuffers) and others.

    The difference, at least in Burst world is that these virtual memory allocations get reported as memory instead of virtual in KVM for example. Java allocates to make sure it's there and reserve it. Does NOT mean it's used.

    Due to the way garbage collection and the JVM works, even if you see a high memory usage, it can just mean the garbage collector hasn't kicked off yet - doesn't mean your application is memory hungry.

  • no vswap. have you compared memory comsumption on same java app (e.g. Alfresco on Tomcat) running on both ovz vswap vs kvm/xen?

  • @jcaleb said: no vswap. have you compared memory comsumption on same java app (e.g. Alfresco on Tomcat) running on both ovz vswap vs kvm/xen?

    Provided there's enough VSwap it's very similar in most cases. We run a lot of enterprise applications on OpenVZ VSwap.

    (ad alert: this is why we give enough VSwap on all of our VPS plans)

  • I have no vswap ovz at the moment. WIll try to test in the future =)

    but many providers dont yet support this.

  • @jcaleb said: but many providers dont yet support this.

    Hence why we decided to support this right from the start and standardize our nodes. I know BuyVM is testing it.

    @jcaleb said: I have no vswap ovz at the moment. WIll try to test in the future =)

    If we're interested, we could offer a limited trial, just to get your hands on VSwap. PM me.

  • PM sent!

  • Got my trial VPS, thank you @concerto49

  • @concerto49

    The big difference is that OpenVZ lets containers choose where they take their RAM from and oy limit the usage, thus the RAM becomes defraged. (ECC RAM could partly fix this)
    Xen allocates the RAM on boot of the VM, so that the VM has its own RAM partition where the guest operation system decides how RAM is being used.

    Xen PV is thus GREAT for Java!
    As it can fill the RAM (defraging) better and because just like OpenVZ the CPU barely has overhead.

  • @BronzeByte I don't understand. Can you explain further, on the viewpoint of VPS users?

  • @jcaleb

    Xen reserves a SOLID BLOCK of RAM for your VM that you can (ab)use how you want it without affecting anyone.
    In OpenVZ processes are seperated by namespaces but still use the same RAM and that's also why overcomitting RAM is so easy on OpenVZ.

    Summary:

    • Xen gives you RAM
    • OpenVZ limits your RAM
  • @BronzeByte said: The big difference is that OpenVZ lets containers choose where they take their RAM from and oy limit the usage, thus the RAM becomes defraged. (ECC RAM could partly fix this)

    Only if providers super oversell/overload their nodes. If there is "real" memory available, the situation is the same.

    As far I know Java requires continuous block of memory anyhow, so say even if you had enough free memory and it's not continuous it would fail.

    So it's a moot point.

  • @BronzeByte thanks for the explanation

  • erhwegesrgsrerhwegesrgsr Member
    edited November 2012

    @concerto49

    Your statement is invalid.

    Here's a scenario:
    If you had a node with 16GB of RAM.
    You have 15 people with 1GB each.
    They all boot up some app that uses 512MB.
    Then they would consume the first 50% of the RAM block.
    Now, half of the people decide to enable some function where the app starts using 768MB.
    The process has to reboot, so it leaves a 512 gap somewhere in the middle and boots at 50% of the RAM.
    The new 768 doesn't find in the 512MB gap and needs to place 512MB on memory DIMM #1 and the other 256MB somewhere on DIMM #3.
    The same (defragmentation) can happen to your disk when your users first used files of 1GB big, but now 2GB.

    I'll make a nice drawing later on.

  • @BronzeByte said: I'll make a nice drawing later on.

    Whats the drawback? Will it report more memory consumption on my vps?

  • concerto49concerto49 Member
    edited November 2012

    @BronzeByte said: Here's a scenario:

    No. The JVM doesn't allocate memory on the fly. It doesn't work that way. It reserves in continuous blocks. Also, even if you have an array of objects they can be sparse just as well.

    Even IF Xen had a continous block, who says the application can't slice it up during allocation? There is no definite answer.

    Any FYI the JVM supports NUMA. It's smart.

    It's a moot point that there is a gap unless you're talking about a graphics application or something that really needs the full continuous block of memory. It might not even be faster.

    I'm not promoting OpenVZ or Xen. They both have their benefits, but please don't add to the myths.

  • Nick_ANick_A Member, Top Host, Host Rep

    I don't have any specific stats to support this, but Java seems to run fine on VSwap systems.

  • When vswap is 0 (only guaranteed ram is given), then Java eats lots of memory on OVZ right?

  • Java (Minecraft) works fine on our OVZ vSwap VPSes.

  • @jcaleb said: When vswap is 0 (only guaranteed ram is given), then Java eats lots of memory on OVZ right?

    It does to the end user. With VSwap, it just goes to swap as not all of it needed. Try spawning lots of threads for example in Windows and you will see the memory usage stay about the same. They go to swap / virtual memory.

  • Just bumping.

    Sorry, it took me sometime to test. But thanks to concerto49 for giving me a test account.

    I compared my KVM and OVZ (from cloudshards) on exactly the same setup. openjdk6, tomcat, mysql (default no tuning), a 100mb sql database innodb, and average size grails application i wrote (around 50-100 screens, 15 reports).

    On KVM, it eats 350-400mb ram.

    On OVZ it eats from 250-300mb.

    I'm surprised its lower.

  • is there a way to limit the ram consumption by java?
    i'm planning to use crashplan on a leb which uses java and the java eats ram so much that some guys using crashplan write cron to kill java process from time to time..

  • @jcaleb said: I'm surprised its lower.

    I told you OpenVZ using more memory is a myth. It may it may not. Depends on your setup. Then everything does :)

    Glad it's doing well for you.

    @Pats said: is there a way to limit the ram consumption by java?

    -Xms : min heap memory
    -Xmx : max heap memory
    -Xss : thread stack size
    --XX:MaxPermSize= : permanent generation size
    --XX:ReservedCodeCacheSize= : code cache size

    Use Java 7 if possible. There are a lot more parameters to play with, but that gets complicated :)

  • @concerto49 I can't believe it either. I use a real life application that I deployed to a client and using real life data. Performance also is so much better than KVM, very snappy. I mean like normal things such as restoring from dump, to performing java reports are at least 2x faster.

    Thanks man for giving me a test vps to try these out

  • @jcaleb said: Thanks man for giving me a test vps to try these out

    No worries. Glad it helped.

    @jcaleb said: @concerto49 I can't believe it either. I use a real life application that I deployed to a client and using real life data.

    Been testing and deploying Atlassian Java based web applications under OpenVZ for a while now. It's working great.

  • I initially thought I would go beyond the 512mb you gave me =)

  • In your sense, what would then be the optimum balance RAM/vSwap on an OpenVZ LEB to allow java simple applications?

  • @Miky said: In your sense, what would then be the optimum balance RAM/vSwap on an OpenVZ LEB to allow java simple applications?

    All our VPS plans are 1:1, e.g. 512MB RAM | 512MB VSwap.

    I don't think you need that much VSwap for simple Java applications - it helps greatly when you have a Java Web Application that spawns a lot of threads though for example.

  • jcalebjcaleb Member
    edited November 2012

    So maybe just 512mb vswap regardless of guaranteed ram right? e.g. 1024 ram / 512mb vswap, 2048 ram / 512mb vswap.

    btw, when i tried my same config on an ovz without 0 vswap, it eats 700mb-800mb

  • @jcaleb said: So maybe just 512mb vswap regardless of guaranteed ram right? e.g. 1024 ram / 512mb vswap, 2048 ram / 512mb vswap.

    It depends on the application as said.

    For 1024MB we have 1024MB VSwap.
    For 2048MB we have 2048MB VSwap.

    @jcaleb said: btw, when i tried my same config on an ovz without 0 vswap, it eats 700mb-800mb

    Do you mean with 0 VSwap? Hence the memory usage.

    In KVM/Xen world it just goes to the swap file. In this case it goes to VSwap. 0 VSwap = goes to memory.

Sign In or Register to comment.