This project is read-only.

the first response time of the website after some hours takes too long

Topics: Troubleshooting
Oct 31, 2013 at 8:23 PM
Hi, I've got issue with duration of the first response time of my website after a while on my virtual server. When I start the site in IIS, I know that there is some loading going on and it can take some time. After that the speed of other pages is good except my gallery content type (I'll explain it later). But when I try, let's say after 4 hours, visit some page again (page content type), the response time is about 7 seconds.

My gallery is another problem. It's a content type with media library field, so I can easily choose and sort some images (about twenty, not hundred and I know that they are treated as content items). I have 10 galleries, and every one of them takes about 10 sec to display for the first time and then it's fine.

The SysCache and Output Cache module are turned off, Keep alive and Warmup is on. Cache modules are off because I want to see how the site reacts if the cache expires or just isn't loaded, server is restarted...

I'm using SQLite and my virtual server has 3 GB of RAM and two virtual cores. The cores aren't dedicated and what I understand from my server provider the minimum of real performance is 1/2 half of some Xeon core. The cpu load usually doesn't get over 50%. AppPool recycle interval is set to 29 hours.

I'm logging the response with my simple HttpModule and it looks like that:
some hours of keepalive
Keepalive tells me that application is loaded, AppPool is recycled after one day, not after hours, cache is off and still the first access to my /gallery-one after /page-one is 10 seconds but next request of /gallery-one takes only 400ms. If we forget about this gallery thing, there's still very long response of first simple page after some hours of idle keepaliving.

I've tried to describe my issue as best I could. Do you see any obvious problem? Like this simple orchard site (4 pages, 10 galleries with 20 images each) can't run smoothly on this kind of virtual server? Would it run better on some entry level dedicated server? I mean some C2D, 2GB RAM for I don't wan't to spend too much for one site.

Thank you in advance for your replies.
Nov 1, 2013 at 11:32 AM
You're using SQLite? How and why?

There's certainly no issue with your hardware (such an Orchard sites, especially without load runs smoothly even on an Azure XS VM).

Ten seconds seems like JITting, not an app start. I mean that regardless of your app being recycled only once a day the first page loads for every unique page after recycling will be slower than usual, as even though the app itself has started the individual pages should be compiled on the first view. E.g. after Orchard is started when you first open a blogpost it could well take 10 seconds as everything handling that request is being compiled. Every subsequent request to any other blogposts will be fast, as then the code in question will be already compiled.

Is the idle timeout for the worker process also set to 0 BTW?
Nov 1, 2013 at 1:20 PM
Sorry, not SQLite but SQL CE :)

Ok, I understand... It should be like regular page, first one is slow, the second one reacts in ms because it uses already compiled code. My content type doesn't act like that. The second gallery takes approximately same amout of time to render like the first one, but after that it's quick. It seem that every single gallery is compiled separately. I'm glad that hardware isn't the cause so it must be in my code.

My view for MediaLibraryPicker:
    var field = (MediaLibraryPickerField) Model.ContentField;
    var contents = field.MediaParts;

 @foreach (MediaPart content in contents)
     var mediaPart = ((ContentItem)content.ContentItem).As<MediaPart>();        
    <div class="col-md-4">
        <a href="@Display.MediaUrl(Profile: "GalleryThumb", Path: mediaPart.MediaUrl)">
            <img src="@Display.ResizeMediaUrl(Width: x, Height: y, Mode: z, Alignment: a, Path: mediaPart.MediaUrl)" />
Could it be one of the Display methods (MediaUrl or ResizeUrl)? I will look into it and test it.

The idle timeout in IIS Manager was set to default value which was 20 minutes. I changed it to 0.

Thank you
Nov 1, 2013 at 1:39 PM
Don't know much about the Media Library's implementation details but it could well be relatively slow on its own with a lot of items.

If you have non-trivial amount of data you definitely need a standard SQL Server, not SQL CE: this will make DB-related tasks perform better. SysCache gives you a big boost too by eliminating unnecessary duplicated DB calls. I know you want to test, but SysCache is something that ideally would never be turned off (but unfortunately it can cause consistency issues).
Nov 1, 2013 at 5:21 PM
It's caused by Media Library... I put stopwatch outside the foreach to found out that it took 99% of time of the several second long request. After commenting the code inside the div these absurd times disappeared. I guess I need to to avoid these MediaUrl things and store generated media urls somewhere else.
Nov 1, 2013 at 5:48 PM
I have already fixed some perf issue on it, but still have to look into another related one. There is a bug open for that.