Kohei Nozaki's blog 

Memory usage tuning of Java8 on Linux


Posted on Thursday Feb 19, 2015 at 06:20PM in Technology


I have a WildFly and a Apache James server instance on Linux based VPS which have 1GB RAM. these days they allocates large swap area while they only used fewer than 1GB for actual memory consumption. performance is not bad for just serving without any administrative operations, but some operation tend to slow due to large swap size so I configured some to reduce swap size.

Environment

  • CentOS 6.5

  • Oracle JDK8u31

Before

top - 21:06:05 up 118 days, 19:07,  1 user,  load average: 0.01, 0.02, 0.00
Tasks: 123 total,   1 running, 122 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.5%us,  0.2%sy,  0.0%ni, 99.3%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1020224k total,   947560k used,    72664k free,     5692k buffers
Swap:  2097144k total,   500732k used,  1596412k free,    65308k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP COMMAND
29457 wildfly   20   0 3183m 438m 6152 S  0.3 44.0  41:27.36 355m java
19826 james     20   0 2725m 281m 6788 S  1.0 28.3  28:28.08  39m java
...

Configure JVM params

Set following JVM params to James:

-XX:ReservedCodeCacheSize=100m
-XX:MaxMetaspaceSize=128m
-XX:CompressedClassSpaceSize=128m

Set following to wildfly as well:

-XX:ReservedCodeCacheSize=100m
-XX:MaxMetaspaceSize=256m
-XX:CompressedClassSpaceSize=128m

After

These parameters reduced swap size as follows:

top - 19:33:09 up 119 days, 17:34,  3 users,  load average: 0.41, 0.24, 0.10
Tasks: 130 total,   1 running, 129 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.3%us,  0.3%sy,  0.0%ni, 99.3%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1020224k total,   924232k used,    95992k free,     8400k buffers
Swap:  2097144k total,   407972k used,  1689172k free,    90320k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP COMMAND
30181 wildfly   20   0 2141m 405m 6308 S  0.0 40.7   5:11.08 272m java
29949 james     20   0 1677m 249m 6720 S  0.7 25.0   5:52.41  46m java

UPDATE: Now swap size grown as almost before adding configuration so sadly now I’m not sure whether it works or not.

Setting swappiness

vm.swappiness defines how often the swap file is used. setting lower value means lower swap size but it doesn’t simply mean better performance. you can adjust it via executing following command to apply instantly:

sudo sysctl vm.swappiness=1

Add following definition to /etc/sysctl.conf to set it as persistent one:

vm.swappiness = 1

Following discussions may be useful:


Importing entries into Roller


Posted on Thursday Feb 19, 2015 at 11:54AM in Technology


Recently I migrated old articles that wrote within hand made blog (?) engine to Roller. there’s a useful Groovy script that placed in source distribution of Roller. I referenced that script and created a standalone Java program which imports entries that saved as RSS 2.0 XML. the program is intended to use with WordPress WXR file but I’ve never used it with real WXR file which WordPress produced because I don’t have any WordPress instances for my own. I used it for a XML file which produced by Rome and before import I added some tweak by hand.

I think it’s harder to use without any modification but it may be helpful for someone wants to import entries with API for Roller, so I pushed the program into GitHub.