Running Orchard on shared hosting

Tags: orchard, hosting

Trying to run Orchard on shared hosting can run you into many problems. There’s already been a long discussion about that on Orchard discussion board. The main issue noticed is a long Orchard loading time, especially when accessing the site for the first time.

Orchard is a very complex application which needs a lot of preparation stuff at startup. Unfortunately shared hosting providers care the most about site density on their servers and do frequent AppPool restarts so to allow other sites to reuse the server resources. Every AppPool restart forces Orchard to load itself from scratch and do the so-called “cold-start”. Also, on less frequently visited sites the AppPool will be additionally recycled because of long idle times.

There are two approaches to lessen the impact of those on your visitors’ experience (of course if AppPool recycling is the case):

  1. Use ping service to shorten the application idle time. It will ensure that your site is constantly running by pinging the specified URL in specified time periods and will automatically force cold-starts. Some of such services were mentioned in this thread.
  2. Use Application Warm-Up IIS plugin. This is the much better way as long as you have access to your site via IIS Management Console. In my opinion this is a must-have plugin! It ensures the application gets a hot-start even when AppPool gets recycled. Basically it makes your application start before the first request arrives.

Hope you find it helpfulUĊ›miech

Cheers!

5 Comments

  • Kamil said

    Im not sure but there may be a third solution to use healthMonitoring like ping http://msdn.microsoft.com/en-us/library/ms998306.aspx

  • filip said

    Since Orchard is using NHibernate to help with its CRUD, there is a startup penalty when loading, parsing and compiling mappings. One way to speed that up would be to save the prepared configuration to a file and then loading it from there. Something like this:

    // configure and save Configuration cfg = new Configuration().Configure(); // code to save the config to a file (only done once and after domain model changes)

    // load config var b = new BinaryFormatter(); return b.Deserialize() as Configuration;

    HTH

  • Hoang Dung Le said

    The problem is not about Orchard complex structure, but it's because of NHibernate. NHibernate take a lot of time when we first load our website. I think if Orchard chose EntityFramework, It posibly is faster.

    From this year, all of my new web apps base on EF4 Code First. It's cool!

  • pszmyd said

    @Kamil: Yes, this could be useful. There is also a module (KeepAlive by Sebastien Ros) for keeping the site alive (by pinging).

    @Filip: Orchard does it exactly like you said. The mappings are saved and reloaded from the config file when app restarts. So it's not the case. Rebuilding mappings happens only when changes are detected (eg. when you install a module). You can find the mappings.bin binary config file /AppData/Sites/. Mappings are persisted for every tenant separately.

    @Hoang Dung Le: Maybe, but it would clearly need some real-world comparison. I'll ask the Team if they made some comparisons. Afaik the choice for NHibernate was mainly because of it's maturity comparing to EF.

  • Renaud Paquay said

    Small clarification wrt the "mappings.bin" file: unfortunately, Orchard is unable to create this file when running in "Medium Trust". Using the the Binary Formatter, in particular, is disallowed. So, if your shared hoster does support full trust, please make sure to remove element from your web.config file. This will improve startup time.