Sitecore 8.2 was released with Microsoft Dependency Injection and with the recent release of Sitecore 8.2.1 it was finally time for me to do what I have been promising. I wanted to take an existing solution which was on production using Simple Injector (My Favorite framework), test it again the same solution but with Microsoft DI.
So here is some information:
- Two sites were setup, one for Simple Injector and one for Microsoft DI
- The code is exactly the same, except the DI framework has been swapped out
- No other code changes were made to the code base
- The solution runs on 8.2 rev. 161115 (8.2 Update-1)
- The solution uses Web API calls as well and so the Web API controllers were also registered
- I used Kam‘s ServiceCollectionExtensions and made a change to include Web API controllers with the help of one Mr. Sean Holmesby. The modification is added as a comment on Kam’s Git.
- Each site was isolated to an identical environment
You can refer to my previous blog post to implement Microsoft DI: Microsoft Extensions Dependency Injection (DI) with Sitecore 8.2 Sample Project
I ran the following two tests on both the sites:
While the both tests were running, I took some sample screenshots of the server performance and the current load. I also compared page load times for specific pages. Here are some screenshots.
Results of Test 1
Test 1 – Page Load Times – Simple Injector
Test 1 – Page Load Times – Microsoft DI
Test 1 – Server Performance – Simple Injector
Test 1 – Server Performance – Microsoft DI
Test 1 – Winner – Microsoft DI
Now for test 2!
Results of Test 2
Test 2 – Page Load Times – Simple Injector
Test 2 – Page Load Times – Microsoft DI
Test 2 – Server Performance – Simple Injector
Test 2 – Server Performance – Microsoft DI
Test 2 – Winner – Microsoft DI
Over all with Microsoft DI, the server performance was much better. Needless to say that I will be using Microsoft DI. Hope Sitecore can update the Microsoft DI version in the upcoming versions.
If you have any questions or concerns, please get in touch with me. (@akshaysura13 on twitter or on Slack).
11 thoughts on “Bring it on! – The battle rages between Simple Injector and Microsoft DI in Sitecore Performance Testing land far far away!”
I’m surprised that Microsoft DI is so much faster than Simple Injector. I wish there was a way to port Simple Injector’s “Verify” functionality to Microsoft DI. That’s Simple Injector’s “killer feature” in my opinion–having a check for DI misconfiguration.
what is the tool you used to do the above performance test ?
Great post Akshay!!! Thanks for making the case and making it easy to choose the best DI !!! 🙂
Great post. I’d like to run a similar benchmark vs Autofac, but I think I know already what the result will be.
Totally agree. I love Simple Injector.
Hetal, thank you. I would not say Microsoft DI is the best over the others available but in this case I am not using any complicated DI functionality so I am able to use the default DI framework bundled by Sitecore and it happens to run faster. 😉
Thanks Chris. The trick is to do it on a real solution rather than a test solution. It took me a while to get this setup and run on a production solution. I am hoping to run this again once I move it to another environment so that we can validate the results.
Interesting Post Akshay. I did wonder who would win the battle here and it’s nice to see the default DI in SC 8.2 is faster. We are using SimpleInjector on our 8.1 implementation so during the next upgrade it might be worth moving to MS DI. Thanks for taking the time to do this.
By taking a look at the performance difference between Core DI and Simple Injector in Daniel Palme’s excellent benchmark (http://www.palmmedia.de/Blog/2011/8/30/ioc-container-benchmark-performance-comparison), you’ll see that the performance difference between the two is very small (with Simple Injector being the fastest). But the real life difference between the two is so small (we’re talking micro seconds) that it doesn’t explain the big difference between the two in your results. Those containers are both so fast, that each container will probably take up less than 1% of the total time a single request takes.
The total time each container takes per requests is probably so insignificant, that I don’t believe you can draw any conclusions from your tests on which one’s the fastest. You might want to rerun your tests in a different order, on different machines multiple times over.
Thank you for commenting. I understand what you are saying but here is how I setup the tests and hopefully you can suggest how I could improve it.
– Took gold source which currently runs on prod and uses Simple Injector
– Deploy to the same IIS server and DB server which run Sitecore CMS
– One site for site running Simple Injector
– One site running Microsoft DI
– Keep in mind that, Sitecore 8.2.1 by default uses Microsoft DI for its own internal implementation.
– Only one site was running at one time
– Before each test, the server was recycled
– The same two tests were run on the two sites – three times each to get averages
– I used LoadImpact.com to run the tests
You keep quoting Daniel’s blog, which is what I used to make the decision to use Simple years ago. Since Microsoft DI is included as part of Sitecore, I decided to give it a chance. If you have any suggestions on top of this please let me know. Otherwise I am sticking to Microsoft DI and will run future tests on load balanced environments and post the results.