GeoServer tomcat JAVA Optimization

# GeoServer Tomcat JAVA Optimization# geoServer的tomcat的java的性能优化策略

参考【geoServer cookbook】

we created a startup script for the automated startup of GeoServer
on Linux. Now, you will edit the script with proper values for Java runtime parameters.
Each parameter will be briefly described in the following steps:

1. Open the startup file we created in the previous recipe:

$ sudo vi /etc/init.d/tomcat

Note
vi is one the most famous editor on Linux. System administrators and developers
often love it for its flexibility and power. On the other hand, it has a steep learning
curve and newcomers may find its command mode / insert mode dual nature
uncomfortable. On Debian distributions, such as Ubuntu or Mint, you may find nano
a more user-friendly console editor. It goes without saying that you can use a
powerful IDE such as gedit or jEdit if you can access a desktop environment

2. Locate the following code line. If you didn’t modify the script, it should be line
number 15:
export CATALINA_HOME=/opt/Tomcat7042

3. Insert the following lines of code after it:
HEAP="-Xms2048m -Xmx2048m"
NEW="-XX:NewSize=128m -XX:MaxNewSize=128m"
RMIGC="-Dsun.rmi.dgc.client.gcInterval=600000 -
Dsun.rmi.dgc.server.gcInterval=600000"
PGC="-XX:+UseParallelGC"
PERM="-XX:PermSize=128m -XX:MaxPermSize=128m"
DEBUG="-verbose:gc -XX:+PrintTenuringDistribution"
DUMP="-XX:+HeapDumpOnOutOfMemoryError"
SERVER="-server"

4. Now go to the line, just after the ones you just inserted. We need to add all values you
set in the JAVA_OPTS variable. JVM will read it at startup and use your values:
export JAVA_OPTS="-Djava.awt.headless=true $HEAP $NEW $RMIGC $PGC $PERM
$DEBUG $DUMP $SERVER"
5. Save the file and restart your Tomcat server.

We inserted a few extra parameters to the script. This tunes the JVM environment and
helps to increase your server’s performance. Let’s explore what we added and why it is
important:
HEAP: This parameter lets you reserve enough memory for GeoServer. It really
depends on the memory availability on your system. 2 GB, as indicated, is a good
figure. You may want to decrease it if you are hosting on a tiny cloud machine, where
total memory size is limited:
HEAP="-Xms2048m -Xmx2048m"
NEWSIZE: This parameter lets you are reserve space for new objects created by
GeoServer. This values shouldn’t be more that a fourth of heap; reduce it
proportionally if you need to reduce your heap:
NEW="-XX:NewSize=128m -XX:MaxNewSize=128m"
GARBAGE COLLECTOR: This parameter sets the frequency at which the Java garbage
collector, which is used to destroy unused objects, should be run. Once every 10
minutes, as suggested in the recipe, should be more than enough:
RMIGC="-Dsun.rmi.dgc.client.gcInterval=600000 -
Dsun.rmi.dgc.server.gcInterval=600000"
PGC: You should also add a line to use the parallel garbage collector, which enables
multithreaded garbage collection. This improves performance if more than two cores
are present:
PGC="-XX:+UseParallelGC"
PERM: This lets you increase the maximum size of permanent generation (or permgen)
allocated to GeoServer. This is the heap portion where the class bytecode is stored.
GeoServer uses lots of classes and it may exhaust that space quickly leading to out of
memory errors. The code that let’s you increase the size of permgen is as follows:
PERM="-XX:PermSize=256m -XX:MaxPermSize=256m"
DEBUG: This parameter enables Java to perform tracing. This may greatly help if
things go astray. The code for it is as follows:
DEBUG="-verbose:gc -XX:+PrintTenuringDistribution"
DUMP: This parameter sets Java to create a dump of the memory state when your
server ends in an out of memory case (OOM). It does not cost anything unless
triggered, and may be useful to debug tricky bugs. The code that let’s you achieve
that is as follows:
DUMP="-XX:+HeapDumpOnOutOfMemoryError"
SERVER: This parameter is used for forcing the server JVM. On most Linux systems,
it is there by default. However, having it explicitly set doesn’t harm. The code for it is

评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值