Wednesday, 10 October 2012

MapGuide Server cache priming

Consider this fragment of code to create a MgMap from a Map Definition resource id

Here's a sample set of numbers from this code on a first run.

Notice how subsequent MgMap initializations from the same Map Definition after the first one are near instantaneous? This is because the Create() call caches frequently accessed information for future calls, like:

  • Feature Schemas
  • Class Definitions
  • Identity Properties
  • Spatial Contexts
  • Feature Source documents
Now for a map like the Sheboygan sample, these numbers don't mean much, but for a really chunky map that has 100s of layers, the effects of this cached information will be more apparent.

Now you may be wondering, is there a way like Map Tiles, to pre-cache such information (ie. Basically automatically MgMap.Create() any Map Definitions you specify)?

Yes there is, and it's called the PreCacheMap configuration property in serverconfig.ini

Set this property to a comma-separated list of Map Definitions, and the MapGuide Server will MgMap.Create() each one in the list as part of service startup, and pre-cache all the associated information that comes with the Map Definition and hopefully reduce that "cold start" lag.

No comments: