Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance of Microsoft Unity Container

I am reviewing a project that has used Microsoft Patterns and Practices Unity Container.

There is a single container with 40 registered types, an instance of the container is created for every web service call.

I am wondering:

  • Is there a performance problem due to registering so many types?
  • Could the unity container be shared between web service calls?

The web services are hosted in IIS.

like image 930
Shiraz Bhaiji Avatar asked Dec 01 '22 09:12

Shiraz Bhaiji


2 Answers

Unity caches all sorts of stuff under the hood the first time a resolve is done. This significantly improves performance on later resolve calls. If you create a new container on every request, you're throwing out those caches.

Keep the container around between requests.

like image 61
Chris Tavares Avatar answered Dec 16 '22 03:12

Chris Tavares


Please create the container and register all types during Application_Start. We've done this for around 200 + types in a large project (wcf and asp.net mvc) and have had no issues.

Thanks

like image 36
SharePoint Newbie Avatar answered Dec 16 '22 03:12

SharePoint Newbie