views:

438

answers:

2

I'm using mapserver to create a map that will be displayed with the google map api. I'm encountering performances issues.

My maps are all in shapefile format.

I run tests to get time to render maps.

When rendering a map with the shp2img tool, using command line

shp2img -i gif -m C:\myfolder\mymapfile.map -o C:\myfolder\test.gif -all_debug 5 -map_debug 5

I get the following metrics from the log files:

[Thu Apr 30 13:50:19 2009].148000 msLoadMap(): 0.000s
[Thu Apr 30 13:50:19 2009].180000 msDrawMap(): Layer 0 (PWorld2), 0.032s
[Thu Apr 30 13:50:19 2009].180000 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 30 13:50:19 2009].180000 msDrawMap() total time: 0.032s
[Thu Apr 30 13:50:19 2009].195000 msSaveImage() total time: 0.015s
[Thu Apr 30 13:50:19 2009].195000 msFreeMap(): freeing map at 01595E18.
[Thu Apr 30 13:50:19 2009].195000 freeLayer(): freeing layer at 0159CD00.
[Thu Apr 30 13:50:19 2009].195000 shp2img total time: 0.047s

When rendering the same map through mapserver, using

http://localhost/cgi-bin/mapserv.exe?mymapfile.map&layers=&mode=tile&tilemode=gmap&tile=1+1+2

log file is giving this:

[Thu Apr 30 13:51:50 2009].664000 CGI Request 1 on process 3520
[Thu Apr 30 13:51:50 2009].664000 msTileSetExtent (-10013744.792915, 8348.961808) (-5009.377085, 10010405.208192)
[Thu Apr 30 13:51:51 2009].23000 msDrawMap(): Layer 0 (PWorld2), 0.359s
[Thu Apr 30 13:51:51 2009].23000 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 30 13:51:51 2009].23000 msDrawMap() total time: 0.359s
[Thu Apr 30 13:51:51 2009].23000 msSaveImage() total time: 0.000s
[Thu Apr 30 13:51:51 2009].23000 mapserv request processing time (loadmap not incl.): 0.359s
[Thu Apr 30 13:51:51 2009].23000 msFreeMap(): freeing map at 01598690.

For the same map, the shp2img tool is rendering map 10 times faster than mapserver. When adding more layers and using the tiling mode for google map, can be up to 10 seconds.

Is somebody knows why mapserver is rendering this slow? Is there a workaround?

A: 

I have a couple of suggestions but no hard answers, I haven't done much mapserver config but I've worked with people who have.

  1. There are a lot of optimizations you can do to mapserver, I'd check the mailing list.
  2. Make the mapfile as small as possible, as opening and parsing the mapfile can be time consuming for mapserver.
  3. Create all the tiles ahead of time and just use mapserver get the files. Tiling on the fly is not very fast.
scottschulthess
I already have made a lot of optimization in mapfile. It looks like optimization make rendering faster with shp2img, but little improvements in mapserver. I was expecting mapserver to be roughly as fast as shp2img tool. I don't understand why shp2img is faster.
Blue
+1  A: 

There are a couple of differences between the shp2img and the mapserv request:

1) shp2img creates a single image, your mapserv request generates tiles. This means that it might have to render 9 tiles for the samen bounding box instead of 1. This generates overhead. Try rendering without the tiles option set and run your test again.

2) You have a small overhead for the cgi request in mapserv 3) Mapserv is pushing the image over http while shp2img is writing directly to disk. 4) You did not specify the layer in the mapserv request which means that mapserv goes looking for layers.

milovanderlinden
3) Make sure and use FastCGI, it makes a huge difference.http://www.slideshare.net/DonnyV/wms-performance-tests-map-server-vs-geo-server
Donny V.