Tuesday, 7 May 2019

postgis - MapServer very weak performance vs. GeoServer - Why?


I search for a good WMS server that support PostGIS at the end I found MapServer as the fastest and best choice.


Every performance test say it's faster than GeoServer because of its native compiled code.


Then when we developed our server side using MapScript (the MapServer extension for PHP).


When we did some benchmark on server and compared it with GeoServer and


Wow! MapServer is 2 to 3 times slower than GeoServer.


We also repeat the experiment with MapServer CGI and results not changed.


Our experiment environments:



  • Windows 7 64 bit


  • MapServer version 6.0.3 (MS4W 3.0.6) (MS4W/PHP Mapscript)

  • GeoServer 2.7

  • PostGIS 2.1

  • PostgreSQL 9.4


The PHP code which used to render tiles and used as WMS server:


if(!isset($_REQUEST['layerId']))
die('Layer Is Not Valid');


$layerId=(int)$_REQUEST['layerId'];

$map=new mapObj(null);
$map->setFontSet(realpath("lib\\server-side\\fonts.list"));
$map->setConfigOption("MS_ERRORFILE",__DIR__.("\\ms_error.log"));

$map->metadata->set('wms_enable_request','GetCapabilities GetMap GetFeatureInfo');
$map->metadata->set('wms_getmap_formatlist','image/png,png,png8,png24');
$map->setProjection("init=epsg:4326");


$layer = new LayerObj($map);

$layer->set('labelcache', MS_ON);
$layer->setProcessing('LABEL_NO_CLIP=FALSE');
$layer->setProcessing('FORCE2D=YES');

$layer->set('name', "MasterLayer");
$layer->set('status', MS_DEFAULT );

$layer->setConnectionType(MS_POSTGIS);

$layer->set('connection', "user=postgres password=psgpass dbname=map host=127.0.0.1 port=5432");
$layer->set('data', "geodata from geo_data as subquery using SRID=-1 using unique id ");

$layer->set('type', MS_LAYER_POLYGON);

$class = new ClassObj( $layer );

$style = new StyleObj( $class );
$style->color->setRGB(255,0,0);
$style->set('opacity',100);


$request = new Owsrequestobj();
$request->loadparams();
$request->setparameter('REQUEST', 'GetMap');
$request->setparameter('LAYERS', 'MasterLayer');
$request->setparameter('FORMAT', 'png8');

ms_ioinstallstdouttobuffer();
$map->owsdispatch($request);


$contenttype = ms_iostripstdoutbuffercontenttype();

if (!empty($contenttype))
{
header('Content-type: $contenttype');
ms_iogetStdoutBufferBytes();
}
else
echo "Fail to render!";
ms_ioresethandlers();

?>

DataBase Data Projection: EPSG:4326


Does anybody know why GeoServer is much faster when it isn't compiled natively? Am I missed something?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...