I have a WCF service that is hosted in IIS6. The important part of the method looks like this:
public MyUser[] GetUsers(string appName, string[] names)
{
List<User> users = new List<User>();
foreach (string user in names)
{
MembershipUser mu = this.ADAMProvider.GetUser(user, false); //Unmanaged call to AzMan
if (mu != null)
{
users.Add(MyUser.CreateFrom(mu);
}
}
return users.ToArray();
}
The performance of this method is very poor when it is called with a large array of user names (over 100 or so). It can take over a minute to return. Also, if this method is called concurrently by more than one client it will time out. I have even seen it bring down the app pool. Please note that in the loop a call to AzMan is being made. AzMan is unmanaged COM component.
To increase performace I am considering a multi-threaded approach. .NET 4 is not an option so Parallel.For is not an option but doing the equivalant in 3.5 is.
My question is will creating a bunch of threads (then waiting for all before returning) actually increase performace? Is there an danger in doing this in an IIS6 hosted WCF service?