[GIS] Many mapfiles with few layers, or all layers in one mapfile

mapfilemapserver

I am using MapServer 6 and defining maps with mapfiles.

I have a page where 20 map compositions (~20*5=~100 layers) are possible by varing LAYER/DATA field and some classes of layers… So I can express each map by a mapfile (20 mapfiles) or I can put all layers in the same mapfile… This is the question,

What is better (have better performance), many mapfiles with few layers each, or one mapfile with all (many) layers?


If the answer need some context… I am accessing Mapserver by this URL, where layer names (L1a,L2b) and mapfile name (MFc.map) can vary,

example/cgi-bin/mapserv?LAYERS=L1a,L2b,L3,L4,L5,L6&MAP=MFc.map&FORMAT=image%2Fjpeg&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=epsg:29183&WIDTH=612&HEIGHT=516&BBOX=….

The combinatory is:

  1. Many mapfiles (c=1..20, a=1, b=1..5): a templating software generated 20 mapfiles, each with ~5 layers.

  2. One mapfile (c=1, a=1..20, b=1..5): a templating software can generate a mafile with all ~200 layers.

Best Answer

The best by far is to use one main mapfile with INCLUDE directives to call other mapfiles (all of them being "simple and specific Map Files" btw). This will definitely speed things up. I tested that and the result is quite impressive. This idea comes from here: http://mapserver.org/es/optimization/mapfile.html

"If you have a complex application, consider using multiple simple and specific Map Files in place of one large ‘do everything’ Map File."

Check this very nice post and blog from Simon, he's a very nice guy working with mapserver and related things: http://smercier1.mapgears.com/blog/?p=37. I used these performance tips and they do work. Here you have another link, but Simon basically explained already that in his blog.

Hope this helps,