Big pages cause the load restart for slow connections

Big pages cause the load restart for slow connections

by Shevchenko Dmitry -
Number of replies: 7
Hello, I have a big problem.
We had a server running Moodle 1.7+ with database. It was accessed through the local university network and through the Internet by distant users, everything worked quite suitable for us.

Recently, we downloaded version 1.7.2+ and copied it to the server. It upgraded the database to 1.7.2+ successfully. However, a huge problem arised. Everything is accessed through local network successfully. However, then some of our users try to open large html pages (in size, with pictures) through the internet, they cannot do that on slow connections (phone modems). More precisely - the page is starting to load, but after some time, before it loads completely, it simply restarts and the load goes again and again.

The problem is not with accessing server through global network, since on speedy connections everything works fine.

I tried to downgrade to previous version and moved 1.7+ code back again, however, the problem did not disappear. Also warnings arised for some modules (forum, for example) - that they cannot downgrade.

What could be causing such problem? We have set up large execution time in php.ini, so what else? Currently our environment is this: Windows 2003 server, Apache 2.2.4, PHP 5.1.4 (came with standard Moodle package 1.7+), MySQL 5.0.24. Everything works just great in local network. What's wrong with the global?
Average of ratings: -
In reply to Shevchenko Dmitry

Re: Big pages cause the load restart for slow connections

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Why would you upgrade from 1.7 to 1.7.2?

The sensible thing would be to upgrade to 1.9.4+
In reply to Tim Hunt

Re: Big pages cause the load restart for slow connections

by Shevchenko Dmitry -
But will this solve this problem? I am not quite sure, also these two versions contain some modifications, that we made ourselves for our needs, for example, support of global groups. We don't feel the real need to migrate, until version 2.0 will become completely stable...
In reply to Shevchenko Dmitry

Re: Big pages cause the load restart for slow connections

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Since downgrading back to where you were did not solve the problem, it is probably a server/network issue, rather than simply a Moodle issue.

1.7.2 is very old. The latest release on that branch is 1.7.8 (I think) and when that was released it was announced that that was the end of support for the 1.7.x branch. Also with hind-sight, the 1.7.x branch was not one of Moodle's finest. Moodle 1.9.x is a significantly better series of releases. So, the recommendation to upgrade is a general one.

When you take advantage of the Open Source nature of Moodle, you have to have a strategy for what you will do when a new version of Moodle is released. That normally revolves around source code tools like diff/patch/winmerge and or version control systems like cvs or git. Anyway, the nest time to you a major upgrade would be a good time to work out how you will deal with this sort of thing in future.
In reply to Tim Hunt

Re: Big pages cause the load restart for slow connections

by Shevchenko Dmitry -
Thanks, will try to migrate to 1.9.4+. However, still the question is curios. The symptoms are precisely like this. The page contains loads of pictures (about 100 each). Now, then the page starts to load, it sometimes stops loading, before it reaches the end of page.

The pictures don't have to do anything with that, it's just the problem with large text content. If server manages to load all the text content, it loads pictures successfully. However, text content loading fails 50% of attempts. What network problems could be actually causing this?
In reply to Shevchenko Dmitry

Re: Big pages cause the load restart for slow connections

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Well, it is really hard to say without more information. So the question is, where can you look?

You should certainly look in your server log files to see if there is evidence there of the requests that are failing.

You could also attack it from the other end by trying to get more information about what the web browser is seeing. For example, you could try installing the YSlow extension for Firefox and using that to monitor the page load.

You could also try measuring load (CPU, memory, disc-IO) on the server.
In reply to Tim Hunt

Re: Big pages cause the load restart for slow connections

by Shevchenko Dmitry -
Yeah, thanks. After furthr investigation I found out that the problem arises while performing function readfile_chunked in filelib.php:
 
$chunksize = 1*(1024*1024); // 1MB chunks - must be less than 2MB!
$buffer = '';
$cnt =0;// $handle = fopen($filename, 'rb');
$handle = fopen($filename, 'rb');
if ($handle === false) {
return false;
}

while (!feof($handle)) {
@set_time_limit(60*60); //reset time limit to 60 min - should be enough for 1 MB chunk
$buffer = fread($handle, $chunksize);
echo $buffer;
flush();
if ($retbytes) {
$cnt += strlen($buffer);
}
}
$status = fclose($handle);

The file we try to output this way is about 127 Kbytes of text, so it should be read and sent to user in one iteration, since the chunksize is about 1 Mb. And I further investigated the code of this function in 1.9.4+, it did not change at all, the algo is the same, so migration will not help much. I will try to use the utilities that you advised, thanks for advice. Maybe there is some parameter in PHP or Apache that blocks the output of such an amount of data? I will try to change the size of the chunk and will see, if that helps.
In reply to Shevchenko Dmitry

Re: Big pages cause the load restart for slow connections

by Shevchenko Dmitry -
Actually now I found the real cause of all the problems. It's the headers generated by send_file in filelib.php. I simply commented the generation of the headers for html pages (not for raw binary data), and everything works now. It seems, that after upgrading Windows 2003 to SP2 some of these headers cause the restart of page load, if it is loaded for too long (for speedy connections that does not happen).