tags:

views:

323

answers:

2

I'm investigating a simple url rewriting setup for iis6 / net 2.0 sites.

I've added a . wildcard mapping in IIS that points to the .net executable. I'm also using the urlMappings element in the web.config to add some rewritten urls. I've moved the config outside of the web.config so I can make changes to the list without forcing application restarts, like so:

  <urlMappings configSource="config\urlMappings.config">
  </urlMappings>

I'd like to allow our content management to add urls to this file so that we can have extensionless friendly urls.

<add url="~/someurl" mappedUrl="index.aspx?page=123" />

This works just fine, but I'm concerned about limitations in the number of entries that I can map in the urlMappings config. I can't seem to find any documentation on this. Has anyone found any limitations?

Thanks.

+2  A: 

Looking inside the urlMapping I see that the mappedUrl are store on UrlMappingCollection that come from ConfigurationElementCollection that virtual have no limits.

The number of urls.

I think that virtual there is no limit on how many you can load.

The load time

The load delay is only on the stating the web, then its keep on a static value, and reloaded only when you change the web.config, or restart the app.

The Memory

Well you have a static collection with all that data called on the start of every request. Depends how many data you going to load on web.config.

The search time

The search time, from my research is not done using any hash method, but they compare the strings together one by one, so here maybe we have a small issue.

This is the code with the heavy search for every url

internal string HttpResolveMapping(string path)
{
    string mappedUrl = null;
    string str2 = UrlPath.MakeVirtualPathAppRelative(path);
    UrlMapping mapping = this.UrlMappings[str2];
    if (mapping != null)
    {
        mappedUrl = mapping.MappedUrl;
    }
    return mappedUrl;
}

here the UrlMapping mapping = this.UrlMappings[str2]; is calling the

protected internal ConfigurationElement BaseGet(object key)
{
    foreach (Entry entry in this._items)
    {
        if ((entry._entryType != EntryType.Removed) && this.CompareKeys(key, entry.GetKey(this)))
        {
            return entry._value;
        }
    }
    return null;
}

I need to check it a little more, but I think there is an issue on search for the url mapping.

In Real Life

Recently I optimize similar code for database calling. I get down the speed from 500ms to 150ms-200ms on a similar loop that is called 20.000-50.000 times in few seconds.

In your case I do not think that this routing is going to called more than 100-200 times in a page call. (and I say 100 because you redirect all call to asp.net, even the images)

So I think that is really depend for how super fast you won your web to be, but the users of you I do not think that they note the different, and on this point you only going to gain 10-20-30ms faster - and we speak only if you have huge amount of urls (maybe more than 1500 urls).

Also the first page with the content is called, then search from this loop, return the page, then the images follows, so the user is going to see the different only on the first 1-5 calls delay of the page and did not understand the small delay on the images.

The optimization here is only going to be measured on programs and not be understand by the users.

The times here is from my experience on my (slow) computers and is to give only the sense of my experience.

Some more words

I think that urlMapping is a ready to go solution that can help anyone to start with, but if some have the time the knowlege and the resource is worth to fix his own url mapping, make it in his needs and super fast if hes like. For start is good to have urlMapping but if you need some more advanced thinks, then you can update it later when your project go bigger.

I am fan of the speed, every second that wait on the computer is a second from our life. How ever if it easy for you to use the urlMapping just do it, make the site workable, and then you check it again after some months.

Aristos
Yes, the collection may be able to hold an infinite number of items, but I'm curious at a practical level if there becomes a (major) performance issue
ScottE
@ScottE I have type some more infos.
Aristos
Thanks for digging into this so fully, Aristos. Do you have experience using urlMappings for a large number of urls? Say, in the 500 - 1000 range?
ScottE
@ScottE yes I have a lot experience not only for url but for many similar loops. The different in speed is very hard to notice, and only after I have optimize all my code in too many points I see the different. There is not only one point that need to be speedy, almost all point must be very fast. Also I use small cache routines in many points that I can do to speed up thinks.
Aristos
@ScottE I do not know your program and I do not know how many times you going to call the 500-1000 loop, before the user see something, but I think at least on the start that you do not have problem with this part.
Aristos
A: 

I´m dealing with a "configSource" in an urlMappings with an xml that contains 34.000 lines (5MB).

When I try to open the web site CPU goes 100% with w3wp.exe process... Sounds like there is a limitation with urlmapping beacuse having a xml of 1MB it works perfectly.

Any ideas about it?

Visual Studio 2005 + IIS

afernandez
No, I was looking for other people's experience with large urlMappings. This is good to know.
ScottE