Thuan
Thuan

Reputation: 1628

Windsor castle 3.2 resolve performance

We have a big web application which is using Windsor Castle for years. The app has about 700 components registrations over 370 services. Almost all of them belong to a root, namely an entry point controller. When a web request comes, we resolve that entry controller and let it handle the request. The issue is that resolving the root component takes about 35 milliseconds. I would say it sounds quite a lot to me.

My question is if the number above sounds normal? Can anyone drop me a hint about what I could do to improve resolving time? Or to check if I'm doing anything wrong?

Thank you :)

Upvotes: 0

Views: 1737

Answers (1)

Steven
Steven

Reputation: 172646

How much time it takes to resolve an object graph depends on a lot of factors, such as:

  • The size of the object graph
  • The registered lifestyles of components and the location of those lifestyles in the graph (obviously if the root object is a singleton, resolving is really fast)
  • The amount of work you do in your constructors

So without further information there is not that much to say. However, I would say that 35 ms. is quite a lot, even for Castle Windsor. I ran a small benchmark over the 6 most used DI containers while resolving an object graph of 881 transient components and the slowest container (Ninject) took 5 ms while the fastest container (Simple Injector) took 0.01 ms (on my machine) to resolve that graph.

Container       |  ms.
----------------+-----
Simple Injector | 0.01
StructureMap    | 0.50
Autofac         | 0.77
Unity           | 1.04
Castle Windsor  | 3.96
Ninject         | 5.03

From this benchmark I would say that 35 ms. is a bit slow for resolving an object graph with that size with Castle Windsor. So make sure that your injection constructors are simple and you do nothing more than checking for null and storing the incoming dependencies. This way you can compose your object graphs with confidence.

btw, you can find a more extensive benchmark here.

Upvotes: 3

Related Questions