Size of a container

Jan 8, 2014 at 8:06 AM
Hi,

I'm just starting to use Unity in a large enterprise application. Just by introducing a new simple web service and new business logic class and new repository for the BL I found that I needed about 3 types registered in the unity container.

I was wondering, is there a practical limit to the number of types that should be registered in a container? Should I be considering sub containers (something I haven't looked at yet)?

Thanks for your help

Graham
Jan 9, 2014 at 12:42 PM
I would only consider using child containers if you need the functionality provided by child containers. e.g. different lifetimes for singleton objects or different mappings for some types.

I'm not sure if there is a specific limit on the number of types that can be registered. Ideally there shouldn't be but I have seen some performance slow down when resolving with tens of thousands of registrations.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Jan 9, 2014 at 1:38 PM
Thanks Randy.

So it is quite normal to have hundreds (maybe thousands) of type registrations in a large enterprise application?

Graham
Jan 10, 2014 at 7:11 AM
I can't really answer definitively since every application is different. Although, to my mind, thousands of registrations is probably rare (although I'm sure people have stories). Also bear in mind that you need not register everything in the container in all scenarios. For example, a Windows Azure application with a Web Role and a Worker Role would probably have quite different registrations for each role. Each role would share some common classes (e.g. ILogger) but the web might have controller registrations while the worker role would not.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to