Boosting Umbraco with Cache
27 May 2013
I like fast things. Making things fast is really fun. I was developing this blog lately, and once I've finished design part, I've checked it's performance on my shared hosting. I am using https://www.blitz.io for the testing, most powerful free tool I've found. If you know something else that is good, please share your wisdom in comments below.
It turned out, default setup Umbraco 6.0.5 + uBlogsy 3.0 beta WebForms/Razor can only handle up to 70 hits per second (hits/sec).
Luckily, it's easy to cache parts of a page with Umbraco. It's called Macro Cache: you can make a macro with logic (either razor, or xslt, even .NET usercontrol), and set desired cache timeout.
To be able to see my changes in real time, I've set my web.config
<add key="umbracoDebugMode" value="true" />
and then used querystring
?umbDebugShowTrace=true
Without caching, default uBlogsy landing page renders ~30ms on my machine. With every dynamic part cached, it takes less than 2ms, according to showTrace information, and 5ms according to log4net log file.
Such setup can handle up to 400 hits/sec. Much better but still not great.
Since my entire page can be cached, default asp.net OutputCache comes to mind. I've used this solution from forum and was able to answer up to 500 hits/sec before getting first timeouts. But in this case, increased load was causing just more timeouts/sec and increased response delay, and not kill IIS instance, like happened with Macro Cached solution.
It was able to perform at maximum 750 hits/sec, while having 70 timeouts/sec.
It's still not clear for me, what Umbraco does exactly, and I'm not sure Caching is implemented properly from performance point of view. I've tested a well-known simple asp.net mvc 3 application with
[OutputCache(CacheProfile = "AnHour", VaryByParam = "None")]
<outputCacheProfiles>
<add name="AnHour" duration="3600" />
</outputCacheProfiles>
and got following results: up to 830 hits/sec without timeouts, up to 1570 hits/sec with 100 timeouts/sec.
Simple default OutputCache is faster, but not TOO much faster. Everything looks about right. Except that I was planning to be able to handle many thousands of hits per second. Linux guys are bragging with such numbers, why can't we?
Do you have any ideas or useful links on how to achieve that? I'd appreciate that!
Resume: I decided to stick with Macro Caching as it's more flexible, doesn't looks like a hack and is easy to manage even from Umbraco backend. I was able to go up from 70 hits/sec to 400 hits/sec. That's a maximum of 34,560,000 hits per day! :)