[GIS] What causes this unexpectedly poor GeoServer/PostGIS/OpenLayers performance

amazon ec2geoserveropenlayers-2postgispostgresql

I am having a tough time making this map run smoothly (play around with it for a bit, you'll see). I have taken a few tips from OSGeo's Making Maps Fast document, but I think there's another issue because:

A) sometimes the map runs just fine, but when I refresh the page it takes a very long time to load and/or times out on some layers, and

B) occasionally when zooming in/out, the Bing basemaps change appropriately but my layers stay at their original scale.

I have not yet taken the step of simplifying/generalizing geometries because, although it may help, I don't think that's the issue. I'm only bringing in a few layers on the initial load, and they're not overly complex, at least not complex enough to slow things down this much IMO. Also, I briefly employed GeoWebCache, but that didn't make much difference either.

In terms of additional performance improvement techniques, I have also followed GeoServer's container considerations and my JAVA_OPTS look like so:

grep -i useparallelgc /etc/*/*
/etc/init.d/tomcat6:export JAVA_OPTS="-server -Xmx256M -Xms48m -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:MaxPermSize=128m -XX:+UseParallelGC"
/etc/java/java.conf:export JAVA_OPTS="-server -Xmx256M -Xms48m -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:MaxPermSize=128m -XX:+UseParallelGC"

Here's my environment:

  • GeoServer 2.1.1
  • PostGIS 1.5.3
  • PostgreSQL 8.4ish
  • OpenLayers 2.11
  • GeoExt 1.1
  • ExtJS 3.4.0
  • Amazon EC2 Linux Micro Instance (awww, 613 MB of memory)

If it helps, here is my GeoServer server status:

Data directory      /usr/share/tomcat6/webapps/geoserver/data   
Locks           0   
Connections     2   
Memory Usage        144 MB  
JVM Version     Sun Microsystems Inc.: 1.6.0_29 (Java HotSpot(TM) 64-Bit Server VM) 
Available Fonts     GeoServer can access 97 different fonts. Full list of available fonts   
Native JAI      true    
Native JAI ImageIO  false   
JAI Maximum Memory  113 MB  
JAI Memory Usage    0 KB    
JAI Memory Threshold    75.0    
# of JAI Tile Threads   7   

JAI Tile Thread Priority        5   
ThreadPoolExecutor Core Pool Size   5   
ThreadPoolExecutor Max Pool Size    10  
ThreadPoolExecutor Keep Alive Time (ms) 30000   
Update Sequence             236

You can look at my code on the website itself, but here is an example of the parameters I'm using for all my WMS layers (tried them as tiled layers, which didn't seem to make much difference):

var wildSingleTile = new OpenLayers.Layer.WMS(
    "Wilderness Areas", 
    "http://50.112.123.161:8080/geoserver/OR_wild_wkspc/wms",
    {
        LAYERS: 'OR_wild_wkspc:OR_Wilderness',
        STYLES: '',
        transparent: true,
        format: 'image/png8'
    },{singleTile: true, isBaseLayer: false} 
);      

I realize that Amazon's micro instance is not the speediest thing in the world, but I don't think it should be THIS slow.

I am quite the noob at just about everything here, including JavaScript and Linux, so any tips and suggestions would be appreciated!

P.S. Sorry for the hideous layer colors, it's not final…

Best Answer

There are quite a few possible issues:

  1. are you reprojecting your data or is it stored in 900913? (it will be faster without the reproject).
  2. That's a pretty large map you are generating so with limited memory you may well be running into issues - look at using tiling and GWC to save redrawing the tiles each time.
  3. if those doen't help then I suspect you need to add more memory.

It's possible there are other issues with styles and layouts but the site isn't currently working so I can't check.