Since many Web browsers do not allow more than two requests to a given domain at the same time, some users map multiple subdomains to the same server. This often improves performance for client applications that make many requests to the same server. Currently, ArcGIS Server and the ArcGIS Silverlight/WPF API do not support multiple subdomains for the same service. However, you can enhance the ArcGIS Silverlight/WPF API to take advantage of a tiled map service hosted on multiple subdomains. This post will demonstrate how to add support for multiple subdomains to a tiled map service layer to improve map initialization, navigation, and overall performance.
The approach involves creating a custom tiled service layer that inherits from ArcGISTiledMapServiceLayer and overriding the GetTileUrl method. In the method simply replace the subdomain part of the URL with any available subdomain hosting the map tiles. You can randomize which subdomain to use, but to ensure that the browser will cache the tiles you’ll need to associate a given row/column/level with the same subdomain. To do this use a simple modulus expression that evenly distributes that load on all subdomains and guarantees that a specific row/column/level will always map to the same subdomain.
The custom tiled service layer looks like this:
public class ArcGISMultiDomainTileLayer : ArcGISTiledMapServiceLayer
{
string[] subDomains = new string[] {
“http://subdomain1.”,
“http://subdomain2.”,
“http://subdomain3.”
};public override string GetTileUrl(int level, int row, int col)
{
string url = base.GetTileUrl(level, row, col);
string subdomain = subDomains[(level + col + row) % subDomains.Length];
return url.Replace(“http://subdomain1.”, subdomain);
}
}
Now you can use this layer in your XAML in place of an ArcGISTiledMapServiceLayer:
<esri:ArcGISMultiDomainTileLayer
Url=”http://subdomain1.myserver.com/ArcGIS/REST/MyMapService/MapServer/” />
Morten Nielsen
Senior Software Engineer
ArcGIS Server.NET, Silverlight/WPF, MapIt
One Response to Using multiple subdomains with a tiled service layer
Leave a Reply
You must be logged in to post a comment.
I have a Silverlight API question :
We deal with projects represented by maps with many layers. We assumed we would have a single arcgis map service per project. So far the silverlight API ArcGISDynamicMapServiceLayer or ArcGISTiledMapServiceLayer do not support access by layer. Creating multiple services per project and spliting the projects into multiple maps is a nightmare. There must be a better way.
Any ideas?
Thanks