[GIS] generally faster in OpenLayers: WMS or GeoJSON

geojsonopenlayers-2wms

I work both with WMS (connection with postgres) and GeoJSON in OpenLayers. I have the impression that a WMS is faster when more feature need to be loaded. And I have the impression that GeoJSON is fast when there are only a small amount of feature. When more features need to load the application is much slower with GeoJSON

What is generally faster in OpenLayers?

And is there way to make a GeoJSON file load faster.

Best Answer

With WMS, the server is querying for these features, creating the image and sending this image over the wire to your client. Factors affecting time of response are database query, image creation and network latency. If these images are being served from the WMS cache, you get an even faster response, as the time required to generate these images will be minimized.

With WFS, the server is also querying for the features, packaging into your output format of choice and sending this over the wire. In both cases, the spatial query will be quick. Network latency will be almost be same although it may be larger for WMS images due to the larger payload. However, the main difference to server response to a WMS and WFS request will come from processing of those features retrieved from the database. Creating an image requires more computation power so response to a WMS request should generally be slower for the same number requested features.

However, your GIS engine has to do the same thing as the WMS server in response to a WFS request; it has to style these features and create the corresponding image and render this on a map. Desktop hardware is slower and since image processing is computationally expensive expect this operation to be slower on the desktop. For a small number of WFS features most of the delay contribution will come from server operation and network bandwidth constraints. On the other hand, most of the delay will come from desktop processing, when you get a large number of features in a WFS response. The reverse is almost true for WMS requests.