jump to navigation

Revving up Geoserver on Ubuntu HH LTS November 10, 2008

Posted by grimmeister in Geoinformatics.
Tags: ,
trackback

Given my setup described at revisiting-geoserver-on-ubuntu
, I am slowly learning (with Tim Sutton) good and weird lessons on how to make geoserver really punch out those services…

No question, you have to do a few things. Geoserver out of the box is relatively minimalist. So a few things need attention, many outlined in the *geoserver in a production environment pages* of the website.

1) Make sure you are using the server jvm.

UPDATE: see Andrea’s comments – the server VM automatically kicks in if you have a server class machine, and configures resource allocation similar to what is described in point 2.

Many docs, including those at Geoserver suggest using a -server flag for the tomcat daemon. This is rather mystifying to myself and others, because Tomcat will not start on our systems if we have this flag set. So my conclusion is that the -server flag is inbuilt into server class machines, or in the Ubuntu 64 bit environment, it is just not available.

I suspect that the kind folk at Ubuntu have distributed the various server flavours with the server jvm as default. To check, type at prompt:

java -server -version

you should receive back something like :

java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) 64-Bit Server VM (build 10.0-b22, mixed mode)

If you get this, you will notice in the file /usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/amd64/jvm.cfg that the server option is default.

If you do not get this message , it is likely that you have not got the sun jdk installed for your server, so fetch and install it, make sure the jdk /bin is first to be found on the path, then repeat the above test.

So the question you really need to answer, is whether /usr/bin/jsvc (commons-daemon on Debian/Ubuntu) is hitting the appropriate JVM.

A question that bothers me a bit is whether there is even a -server flag on 64 bit Ubuntu. This configuration step may be pointless. Seems odd, but my readings have hinted that it is not an option on AMD64 architectures. Given Ubuntu 64 bit seems to work on X86 and AMD64 systems, is it possible that an artifact is a missing -server flag

A little bit vague I know, but may give you enough of a hint to get it working fully.

2) Throw resources at Tomcat

From the get-go give tomcat lots of resources (depending on what else is running on your system). Do this in your tomcat daemon script ( /etc/init.d/tomcat5.5) JAVA_OPTS section. JAVA_OPTS="-Djava.awt.headless=true -Xms144m -Xmx768M -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:MaxPermSize=256m -XX:XX:+UseParallelGC" So, I have set the minimum heap size to 144Mb of memory, maxing out at 768Mb and giving the JVM space to move. I have increased the perm gen space to 256 Mb to aid in classloading and have made use of my multiprocessor setup for garbage collection. There are loads of options available – I am certainly not sure if I am properly optimised here at all.

3) Sessions

I have been grappling a fair amount with a particular issue around Tomcat sessions spiralling out of
control for the geoserver context.

So, make sure (if you are using tomcat, and this seems to be a problem) that you add or modify
the /webapps/geoserver/WEB-INF/web.xml file to include:

<session-config>
<session-timeout>1</session-timeout>
</session-config>

This prevents sessions from being kept alive when idle for more than a
minute. Geoserver does not need them apparently. Be aware that you should probably only do this once your geoserver config is happy – otherwise you will be logging in a lot :-(
4) Logging

make sure to set the log level to PRODUCTION-LOGGING.properties in the server part of the config.

5) Tile Cache

If you are serving WMS, put a tile cache of some variety up in order to reduce the load on the database and geoserver. MetaCarta’s TileCache, GeoWebCache, OSCache, even something like Squid could be used. I have not set it up a tile cache yet, but will add details if and when when I do so (my WMS’s data tend to change quite a lot)

6) Apache Portable Run Time library with Tomcat

The use of this library allows certain aspects of tomcat to be enhanced, with performance gains of 10% or so reported. I guess it would depend on what you were serving!

Binaries for this library can be found, but it is better to compile from source ( with some help from http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Tomcat+Native+Library ).

Make sure that you have the libssl-dev and libapr1-dev packages installed ( sudo apt-get install libssl-dev libapr1-dev)

http://apache.seekmeup.com/tomcat/tomcat-connectors/native/1.1.15/source/tomcat-native-1.1.15-src.tar.gz is some source code

Extract the tarball of the tomcat native lib (tar -xvzf tomcat-native.tar.gz)

cd tomcat-native-1.1.5/jni/native

Configure ./configure --with-apr=/usr --with-java-home=/usr/lib/jvm/java-6-sun-1.6.0.06 (or wherever your jdk lives)

Make and install (sudo make && sudo make install) – generates the library and symlinks in /usr/local/apr/lib

Change to the system library folder ( cd /usr/lib )

Make a symlink to the library  (sudo ln -s /usr/local/apr/lib/libtcnative-1.so libtcnative-1.so)

Edit ${TOMCAT_HOME}/bin/catalina.sh adding the following lines somewhere before java is executed ( LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH )

Restart Tomcat and make sure to check your logs for success or failure. It seems that failure may likely result from problems with IPv6 enabled machines. Disable IPv6 ( edit /etc/modprobe.d/aliases and change the linealias net-pf-10 ipv6toalias net-pf-10 off ipv6 and reboot ) if you can.

7) Native JAI rather than the pure java JAI

This applies in particular if one is attempting to serve raster data, perhaps some satellite imagery but per Andrea’s comment is valuable for improving WMS generation too. So:

fetch the libraries. I got myself the ones from http://download.java.net/media/jai/builds/release/1_1_3/jai-1_1_3-lib-linux-amd64.tar.gz

After unpacking the tarball, I copied the 3 jar files:

sudo cp jai-1_1_3/lib/*.jar  /usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/ext

and the shared library:

sudo cp jai-1_1_3/lib/libmlib_jai.so  /usr/lib/jvm/java-6-sun-1.6.0.06/bin

then restarted Tomcat. JAI appears as available on the Geoserver Admin page.

About these ads

Comments»

1. Andrea Aime - November 13, 2008

Hey there. A few quick comments:
- the page suggesting to use all those VM flags should be updated. What is happening is that Sun JVM has this “server ergonomics mode” that triggers the moment you have a server OS (Linux), more than 2 cores, at least 2GB of memory… that is, whatever recent notebook running Linux. Oh well, anyways, in that mode, server is enabled by default, it grabs way more memory, and it uses the parallel collector by default. I actually observed in benchmarks that trying to set those params manually slowed down performance
- native JAI is not used only to read big raster data, but also to encode whatever raster output, and give quite a noticeable improvement. So install it whenever you use WMS, no matter what’s the data backing the maps.
- session wise, I thought I configured GeoServer to create sessions only when you’re using the admin web UI, hitting GeoServer on the OGC service endpoints should not create sessions… hum… there may be a bug thought. How do you checked session numbers and what happened when they “spiralled out of control”?

Anyways, thanks a lot for the blogs, very intersting stuff as usual :)

2. ADRIAN PATANIA - February 25, 2010

Hi, maybe you have an error here => -XX:XX:+UseParallelGC.
I think the correct option is -XX:+UseParallelGC.
Nice article!

3. Geoserver en entorno de producción (I): Instalación básica | Ni'palante Ni'patras - March 8, 2010
4. Geoserver en entorno de producción (II): Optimizando el servidor | Ni'palante Ni'patras - March 9, 2010
5. Liferay - August 17, 2010

That was remarkable post. I like to read articles that are edifying for they enriched my mind with different knowledge that makes me a better person. These articles especially about recent events, technologies, news, tips and technical skills are the topics that I adore. Keep it up and more power to your website. I look forward for your next article.Thanks Jennifer Liferay


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: