VB.NET 1.1 performance problem with System.DirectoryServies.DirectorySearcher
While working on one of my projects (VB/C# .Net 1.1), I've run into strange performance problems. Controls were loading slowly. After some research, I narrowed the problem - server made several requests to ActiveDirectory through LDAP protocol. Each of those requests took about 7-8 seconds to complete. Same program, written on Java, worked blazingly fast.
Honestly saying, I spent several days fixing this problem.
Problem is caused by DirectorySearcher implementation
Problem was actually caused by System.DirectoryServices library (really a COM wrapper) having some lags with memory allocation, or something like that. I'll add a link once find it in bookmarks.
So, each time request is performed, it at first spends 7 seconds for authentication, or something like that.
Possible solution (worked for me)
Honestly: I did not manage to make this correct. What I've done, is just a plain caching. So, I just saved link to System.DirectoryServices.DirectorySearcher in the static (even not instance, byt in Class variable!), and pinged it in some period.
Caching for DirectorySearcher gave expected results
Yes. First query was awfully long. But subsequent calls were re-using the initialized object, and thus were working blazingly fast! As there are no side effects yet - application is web application, its uptime is more than 2 months.
Useful links on DirectorySearcher performance problem
- Discussion on Bytes - mostly advises to tune up ActiveDirectory. Was not very useful for me
- In .NET2 M$ intrdouced a System.DirectoryServices.Protocols namespace, which may have been used for fine-tuning the connection and protocol details (whether use or not encrypted connection). There were no such stuff in .NET 1.1
- This is a problem with MembershipProvider which people ran into that far. Something like I had, but not similar.
- Also, there are some memory leaks inside .Net DirectorySearcher.
- And finally - how to make DirectoryServices use connection pooling, which basically solves the problem.
No comments:
Post a Comment