In our project we use MVC4 + Umbraco7.2.8. On one of the pages we make around 25 calls to the server simultaneously, each call is full-fledged http get to controller's action which returns cshtml view. Then results are parsed and displayed on a single page. (We know that is wrong design and we are going to replace it with web api calls to get light weight json).
So the problem is that abovementioned process is very time consuming (no wonder, eh?) taking around 19-20 seconds to retrieve and display results of all the 25 calls. Seeking the way to improve performance without changing existing design I noticed that all of the returned view had a Layout page (Master Page), and after I placed all of the code from the Layout page into view and set Layout = null (without changing any functionality) I got dramatic performance boost. Now it takes around 2-3 seconds to accomplish all that 25 calls.
I put traces and I can see (when running with Layouts) that between last trace in the view and first trace in its Layout page is around 800ms gap (not always but often) so when removing Layouts we get rid of those slowdowns. But why is that? I read lots of info and forums and everybody says that using Layouts should have only very light performance impact since it has no more overhead than just calling a function. But my facts say just opposite: just getting rid of master pages we benefit gigantic performance boost. I tried that many times and results are always the same.
Can anybody explain why having/removing Layouts can influence performance so much and what can MVC engine (or Umbraco???) be doing so long while stitching view with its Layout ?