I'm developing an OpenLayers site where the client wants a dozen layers that can be individually turned on and off, which is a bit of a bummer in terms of performance. The data is PostGIS and static enough to cache tiles. The area is quite small geographically but requires 9 zoom levels to allow detailed views. I'm using a cached tiled base map which is fast and efficient.
I've been using Single Tile WMS layers for the other dozen layers, but am wondering if I should used Tiled, cached versions of these. There are other efficiency gains to be made by limiting the buffer, and adding sub-domains such that images can come from tiles.example.com, tiles2.example.com, etc, however all other efficiency strategies aside, I'm wondering at what point the OpenLayers performance difference is for 12 untiled layers, verses 12 tiled layers?
Said another way, at what number of tiled layers in OpenLayers will the performance degrade such that Single Tile layers are preferable? If I have 12 tiles per view, and 12 layers, can OpenLayers handle 144 tiles without bogging down?
Best Answer
The degradation of performance depends on the client's machine - how much memory is available to render DOM elements in the browser, and how fast the CPU can work to redraw these elements when the map changes.
In my experience 144 tiles (each of which will be a new DIV element) should be fine. IE handles several hundred DIVs and FireFox a few 1000 (although if you have FireBug installed that may not be the case).
Testing
It could be useful for you to determine the minimum machine spec you are going to support, and then see how the browser performs with your tiles. This could be done on a virtual machine or using IEThrottle and FireFox Throttle
One way to check how many elements you are dealing with at any one time is to paste the following JavaScript lines in your browser's address bar:
This shows total DIV elements in the page:
This shows number of DIVs in your OpenLayers map, assuming it has an ID of mymap (just change this if it is not the case):
Tile Benefits
The use of cached tiles is likely to far outweigh any negative impacts of using 20 tiles as opposed to one large dynamically generated WMS image.
As you pointed out in your post, performance is likely to be negatively impact due to the maximum number of requests to a single domain, before number of DOM elements causes issues.
Tile Performance
To speed up tile performance you have a number of options, the key ones you have already listed:
Great examples and FireBug performance logging can be found at http://ol-performance.appspot.com/
Training Users
As well as technical solutions, the UI should also be geared up to limiting the number of tiles a user requests. I hope to implement this in the next round of development for http://maps.seai.ie/wind which uses several tiles (and you can see how it performs when all layers are switched on - use the above JavaScript to see how many tiles are loaded). With just three layers there are 160 DIVs in the map, but performance is fine in most setups.
Two things to implement:
I'd be interested to hear your results on how many tiles you managed to load in different browsers.