Orchard CMS slow performance (1.2)

Topics: Troubleshooting
Aug 8, 2011 at 9:59 AM

I am testing Orchard CMS on dev machine and noticed very slow performance on all pages.  Simple page takes about 250 ms to render (on Core i5 CPU). It is unacceptable. How can I speed up Orchard?

Aug 8, 2011 at 10:17 AM
Edited Aug 8, 2011 at 10:17 AM

OK, I found workaround.

1. Rebuild solution in Release mode.
2. Installed Cache modules from Gallery.

Now cached pages took about 50 ms to render.

Aug 9, 2011 at 8:45 AM

I think you should also consider:

  • Publish the application on full-trust.
  • Use SQL-Server, paid version, not expression nor SQL-CE.
  • Disable and fully remove any dev-modules on production, like Codegen and Designer-tools.
Coordinator
Aug 9, 2011 at 8:49 PM

250 ms ? Are you kidding ? This is a great response time for a page. Though I am happy that the Cache module is also satisfying you.

Sep 7, 2011 at 7:53 AM

Some additional ideas to speed up the site - from the visitor/Google SE view:

  • Disable (and remove) all unused modules in live site - Pay attention to dependencies... I used to del Scripting for example what is not a good idea! :) But You will never need Shape Tracing, etc. Also a tip: if You made some url related customisations in Theme/View You will need to keep enabled the Designer/Url Alternates.
  • Use CDN for jQuery downloading (this is tricky, You wil need to hack the jQuery module's resource file urls)
  • Move additional JS to the end - before the closing body
  • If Your theme have Google Fonts, ceheck if the CSS uses all of them, and use direct @font-face in CSS instead of Google's dinamic url css
  • Put Your Analytics/Adwords code directly to layout.cshtml - the module can not use async mode
  • Use async JS every time, You can
  • When ready to start use a CSS combine/minify solution to make one CSS (unfortunately it's possible that some modules will have additional ones)
  • Install and configure the Cache modul (You need to test Your extensions/own modules)
  • Enable and config in web.cfg the gzip compression in Your server
  • Enable and configin web.cfg the http cache (expire times) for every static and dinamic content types (http://www.dotnetfunda.com/articles/article589-best-practice-no-4-improve-bandwidth-performance-of-aspnet-sites-using-i-.aspx)
  • Database Caching Modul - I used to test it with little success. It may be an advanced topic. Maybe someone will write an article about it.
Developer
Sep 7, 2011 at 10:04 AM

250ms on a dev machine (and I suppose you are doing this in Debug mode?) is excellent. On my machine (i7 @ 3,2Ghz) the home page initially loads (after the build succeeded and the dev server started) in about 15s. Other pages take less time, but also only initially. Interesting is that the whole process uses a fraction of the computing power or HDD (it's barely noticeable). However I think this has little to do with Orchard but with the way .NET and its JIT works.

@Epox: nice list of performance tips!

Sep 7, 2011 at 10:32 PM

Just FYI on the jQuery CDN point. You don't necessarily have to hack the jQuery module to do that. You can include your own resource manifest class in your theme and define a "jQuery-CDN" key or something like that to use like:

Script.Require("jQuery-CDN");

Or you can just directly include the CDN version of scripts like this:

Script.Include("http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.2.min.js"); //or any externally hosted script you want to include

Sep 8, 2011 at 8:10 AM

Sorry, I can not agree, because I tested it.

When You simply add a new script to the jQuery manifest.cs - like Google_jQuery or similar - and use the Script.Require("Google_jQuery"); in theme file or use the manual Script.Inculde method, the Orchard system will auto include the original jQuery into the header: 2 jQuery includes will appear in Your html code.

I've also hacked the script to disable this auto include, and now know what is the reason of auto inculde: when jQuery is not in the code, the Orchard Admin area run into errors.

So my production site have a production version of manifest.cs of jQuery plugin, and in it the jQuery url is the Google CDN version... the jQuery UI have also the CDN URL, and the dependency set for this jQuery:

            // jQuery Google CDN
            manifest.DefineScript("jQuery").SetUrl("https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", "https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js").SetVersion("1.6.1");
           
            // Google jQuery UI
            manifest.DefineScript("Google_jQueryUI").SetUrl("https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js", "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js").SetVersion("1.8.1").SetDependencies("jQuery");

The theme just includes the jQuery UI, what incudes the jQuery (auto) too:

Script.Require("Google_jQueryUI").AtHead();

This is a working setup.

 

Additional info for fine tuning of Orchard

Tools: Google Pagespeed (online + plugin), Yslow, http://www.webpagetest.org/

Experiences: Each "onsite technic" have positive and negative effect on the different metrics of website load. The only technics what absolutely positive is the Orchard Cache module (the official, not the Database cache) and the prefect IIS configuring.

To Do:

  • Check if the @font-face imported font are in use. In Contonso theme there was 2 kinds and total 5 versions of fonts imported, but just 3 of them were in use - in the theme CSS. This was about 20+Kb additional, but unused content.
  • Care about Google+ and FB Like async loading: these are extremely slow! You need to use the async versions, so the page will be complete when they will start to be rendered - it a little bad if this was placed above the fold... :(
  • Take time to configure IIS, and web cfg: the compression, and caching is not as easy to configure as described on the net sometimes (we use IIS7.5). But It can decrease Your page loading time by 30-50%!

Avoid:

  • Too many additional javascripts: if You want a js function what is in the jQuery UI, use this, do not add an additional script, cause the CDN version of UI will countain every function.
  • Too many modules: unfortunately Orchard have not got a CSS combine/minify method to minimize the number of CSSs. If You have 5 modules, You may have 2-4 additionaly CSS (auto included in HTML output), but if You have 15, You may have 8-10. Its bad.
Coordinator
Sep 8, 2011 at 8:45 PM

Great info guys. It could be useful to spin off a new thread on the Google CDN topic, which is sure to be of interest to many others.

Developer
Sep 8, 2011 at 11:25 PM

I would add that minification of JS/CSS (and also of html) is already implemented in the OfficineK.HTMLToolkit module and indeed gives a performance boost. An even bigger improvement would be to also combine external styles and scripts (as with todays fast internet connections and many small external files the latency penalty of individually fetching files slows more than the time spent downloading). I hope the module's developer will be kind to implement this too.

Slightly offtopic funfact: it seems that shapes added directly to the body, not to zones cannot require a script to the head, only to the foot section.