Friday, August 25, 2017

Saturday, August 19, 2017

Have fun with Java Memory Tuning



First, by default JVM 1.8 setting, this program metaspace never over 20M, Old Gen never over 80M, Suvivor just around 6M - 24M.
With New Space can bump up to 1.4G, shows this Java Program create many objects for only a very short time and won't last for long. As it is a client program, GC time actually VS memory usage, we can sacrifice some GC time for much less memory as 1.4G is really large.





































1st try:
-XX:MaxHeapSize=256M -XX:MaxMetaspaceSize=64M -XX:MetaspaceSize=24M -XX:NewRatio=2 -XX:CompressedClassSpaceSize=16M -XX:-UseParallelGC

Not bad, with doubled GC pause but I only use 1/5 memory




2nd try:

-XX:MaxHeapSize=128M -XX:MaxMetaspaceSize=64M -XX:MetaspaceSize=24M -XX:MaxNewSize=96M -XX:NewRatio=2 -XX:SurvivorRatio=14 -XX:CompressedClassSpaceSize=16M -XX:-UseParallelGC

Not bad, with 4 times GC pause but I only use 1/10 memory, acceptable since it is just a client program.



3rd try:

-XX:MaxHeapSize=64M -XX:MaxMetaspaceSize=64M -XX:MetaspaceSize=24M -XX:MaxNewSize=32M -XX:NewRatio=2 -XX:SurvivorRatio=3 -XX:CompressedClassSpaceSize=16M -XX:-UseParallelGC


Not good, dramatically increased to 2.3 seconds GC pause, 64M seems really a little over :)


Keep trying difference 256MB allocation.




Thursday, August 3, 2017

Install EtherVPN on Ubuntu Server 16.04 LTS

http://www.softether-download.com/en.aspx?product=softether


wget http://www.softether-download.com/files/softether/v4.22-9634-beta-2016.11.27-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.22-9634-beta-2016.11.27-linux-x64-64bit.tar.gz


su -

apt-get install make gcc zlibc tar gzip openssl libreadline6 ncurses-bin ncurses-base ncurses-term libncurses5 libpthread-workqueue0

tar xzvf softether-vpnserver-v4.22-9634-beta-2016.11.27-linux-x64-64bit.tar.gz

cd vpnserver/
make
1
1
1

cd ~
mv vpnserver /usr/local
cd /usr/local/vpnserver/
chmod 600 *
chmod 700 vpncmd
chmod 700 vpnserver

./vpncmd
3
check
exit

cd /etc/init.d/
vi vpnserver

#!/bin/sh

### BEGIN INIT INFO
# Provides:        vpnserver
# Required-Start:  $network
# Required-Stop:   $network
# Default-Start:   2 3 4 5
# Default-Stop:    1
# Short-Description: SoftEther VPN Server
### END INIT INFO

DAEMON=/usr/local/vpnserver/vpnserver
LOCK=/var/lock/subsys/vpnserver
test -x $DAEMON || exit 0
case "$1" in
start)
$DAEMON start
touch $LOCK
;;
stop)
$DAEMON stop
rm $LOCK
;;
restart)
$DAEMON stop
sleep 3
$DAEMON start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0

chmod 755 /etc/init.d/vpnserver

update-rc.d vpnserver defaults
update-rc.d vpnserver enable



PS: Remember to enable Secure NAT/Virtual DHCP in order for VPN to work