Sometimes you may consider using controllers for all blocks, instead of just having the view engine select the correct view. As far as I know the only real difference is performance. But how much will performance be affected if you choose to use controllers for all blocks?
TL;DR: around 10% better performance without controller, according to my tests.
A while ago I was working on a CMS-implementation which needed a somewhat complex multi-site architecture. I had to choose between using controllers for all blocks, or being forced to use a bit limiting naming convention for blocks. When I made the decision I didn’t know how much using controllers would affect performance. Next time I’m in a similar situation I will know, because I just did some load testing using the lovely free tool Netling
Note that the performance testing I have done are quite un-scientific, but it should at least give a hint. I created a block that basically did nothing, and a controller that just returned the view for that block. Then I just started the site from Visual Studio (IIS Express + LocalDb), and let Netling hit it a couple of times.
This is how my laptop performed
A single block in a content area: Around 215 requests per second
Five blocks in a content area: Around 205 requests per second
Ten blocks in a content area: Around 190 requests per second
A single block in a content area: Around 200 requests per second
Five blocks in a content area: Around 175 requests per second
Ten blocks in a content area: Around 160 requests per second
7-15 % is not that much, but it’s not nothing either. I will continue to avoid using controllers for blocks, but I’m glad to know that it’s not that big of a deal.
At time of writing I was using Episerver CMS 10.10.4.0
4 thoughts on “Performance when using controllers for blocks”
nice. I was always wondering and wanted to measure at some point 😉 now I don’t need to do that.
more interesting would be to know where exactly time is spent. did you have any expensive action filters?
btw, view engine is just one player in whole template resolution process 🙂
Well, it was just a quick test, so no, I don’t really have any more info. I used Standard page on the Alloy site when I tested.
Back to 2013 when Episerver 7.x release, this issue had been reported. See this blog post http://world.episerver.com/blogs/Jonas-Bergqvist/Dates/2013/6/Hidden-template-functionality-in-the-MVC-implementation/
Pingback: Episerver block performance: with controller vs without controller vs IRenderTemplate | Share your code