To improve loading of Moodle see link below, you must have acess to httpd.con to do this.
Please post your other recommendation to further improve the server and moodle.
Martin or anyone do you think of my configuration is right? Wanted a maximum performance so my server won't die...
<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 256
MaxRequestsPerChild 30
</IfModule>
<IfModule worker.c>
StartServers 5
MaxClients 256
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 30
</IfModule>
by the way my server specs is:
P4, 1g ram and 40g hd
<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 256
MaxRequestsPerChild 30
</IfModule>
<IfModule worker.c>
StartServers 5
MaxClients 256
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 30
</IfModule>
by the way my server specs is:
P4, 1g ram and 40g hd
Unless you have a ton of RAM and the database on a separate machine, Maclients is way too high.
Roughly, for a machine _only_ running apache, on Linux, the formula is "maxclients = (MB RAM-32)/30". For 1GB this gives you 32. For Mac OX X, which is more memory hungry, do "maxclients = (MB RAM-128)/30".
MaxClients is a protection for avoiding consuming too much RAM. On a websrever, as soon as you hit virtualmemory (swap), your server stops responding in any useful way.
For better performance, in addition to PHP accelerators, use persistent connections to mySQL *only* if you can shorten the timeout in my.cnf to something really low (10 to 30 seconds). Otherwise, it'll die quickly.
If you are running mySQL on the same box, it's more tricky. Instead of just dividing by 30 (PHP allocates around 25~30 MB when serving a Moodle page) you also factor in mySQL. A good rule of thumb is to give 10MB per-apache to MySQL, so just divide by 40MB instead.
You get the most out of your serve if you serve the max number of requests without exceeding your avaliable RAM, and a low maxclients plus a short timeout for persistent connections are your safety line. Even if Apache complains in the log ("raise maxclients" it'll say) you can only do that if you know there's free memory.
Roughly, for a machine _only_ running apache, on Linux, the formula is "maxclients = (MB RAM-32)/30". For 1GB this gives you 32. For Mac OX X, which is more memory hungry, do "maxclients = (MB RAM-128)/30".
MaxClients is a protection for avoiding consuming too much RAM. On a websrever, as soon as you hit virtualmemory (swap), your server stops responding in any useful way.
For better performance, in addition to PHP accelerators, use persistent connections to mySQL *only* if you can shorten the timeout in my.cnf to something really low (10 to 30 seconds). Otherwise, it'll die quickly.
If you are running mySQL on the same box, it's more tricky. Instead of just dividing by 30 (PHP allocates around 25~30 MB when serving a Moodle page) you also factor in mySQL. A good rule of thumb is to give 10MB per-apache to MySQL, so just divide by 40MB instead.
You get the most out of your serve if you serve the max number of requests without exceeding your avaliable RAM, and a low maxclients plus a short timeout for persistent connections are your safety line. Even if Apache complains in the log ("raise maxclients" it'll say) you can only do that if you know there's free memory.
After extensive benchmarking with a moodle installation on a fanless VIA-EPIA 5000 server (slow by design), I figured that:
Finally, I found one easy way to speed things up for the initial page to have at least a fast reaction for students' first look at the site. I auto-created an index.html to the moodle dir and selected the sequence 'index.html index.php' in the apache config. Therefore, Apache first takes the index.html.
To auto-create an index.html, add the following lines at the bottom of .../index.php:
<?PHP
if (!isset($USER->id)) {
$handle = fopen($CFG->dirroot.'/index.html', "wb");
fwrite($handle, ob_get_contents());
fclose($handle);
}
?>
To allow displaying the user name after login change the lines of .../login/index.php to:
} else if (strpos($wantsurl, $CFG->wwwroot) === 0) {
if (strpos($wantsurl, "/course") === false) {
redirect("$CFG->wwwroot/index.php"); // jump to home
} else {
redirect($wantsurl); // jump to course
}
} else {
redirect("$CFG->wwwroot/index.php"); // jump to home
}
Finally, in the .../lib/weblib.php for functions print_footer and print_navigation explicitly add index.php:
$homelink = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/index.php\">".get_string("home")." <img width=\"11\" height=\"11\" src=\"$CFG->wwwroot/pix/t/left.gif\" border=\"0\" /></a>";
echo "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/index.php\">$site->shortname</a> » $navigation";
Advantages: Users get an immediate reaction when starting on the moodle site.
Downsides: You have to turn off all startpage elements with changing content (news, calendar etc.). You have to erase index.html whenever you add courses (i.e., about twice a year in my case).
Significant improvement might be possible by extending moodle with cache_lite. However, that means changing most php-files.
Regards, Klaus
1. File compression has little effect
2. Different PHP accelerators have no significant effect or even slow down moodle
3. MySQL settings have some effect, but my-huge.ini is too large and slows down.
The min reaction time of moodle seems to result from its modular structure.2. Different PHP accelerators have no significant effect or even slow down moodle
3. MySQL settings have some effect, but my-huge.ini is too large and slows down.
Finally, I found one easy way to speed things up for the initial page to have at least a fast reaction for students' first look at the site. I auto-created an index.html to the moodle dir and selected the sequence 'index.html index.php' in the apache config. Therefore, Apache first takes the index.html.
To auto-create an index.html, add the following lines at the bottom of .../index.php:
<?PHP
if (!isset($USER->id)) {
$handle = fopen($CFG->dirroot.'/index.html', "wb");
fwrite($handle, ob_get_contents());
fclose($handle);
}
?>
To allow displaying the user name after login change the lines of .../login/index.php to:
} else if (strpos($wantsurl, $CFG->wwwroot) === 0) {
if (strpos($wantsurl, "/course") === false) {
redirect("$CFG->wwwroot/index.php"); // jump to home
} else {
redirect($wantsurl); // jump to course
}
} else {
redirect("$CFG->wwwroot/index.php"); // jump to home
}
Finally, in the .../lib/weblib.php for functions print_footer and print_navigation explicitly add index.php:
$homelink = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/index.php\">".get_string("home")." <img width=\"11\" height=\"11\" src=\"$CFG->wwwroot/pix/t/left.gif\" border=\"0\" /></a>";
echo "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/index.php\">$site->shortname</a> » $navigation";
Advantages: Users get an immediate reaction when starting on the moodle site.
Downsides: You have to turn off all startpage elements with changing content (news, calendar etc.). You have to erase index.html whenever you add courses (i.e., about twice a year in my case).
Significant improvement might be possible by extending moodle with cache_lite. However, that means changing most php-files.
Regards, Klaus
Are you sure file accelerators were configured correctly? I tested several with Moodle 1.3.1 and we had between 3-fold and 5-fold increases in throughput... as long as they were configured right.
What was your benchmark tool? I've done a lot of testing with ab (apache bench) and a super fancy Java tool (JMeter) that records your traffic and replays it.
What was your benchmark tool? I've done a lot of testing with ab (apache bench) and a super fancy Java tool (JMeter) that records your traffic and replays it.
Used ab with Turck MMCache and Zend. However, mysql and apache/php/moodle reside on the same EPIA machine and the system is winXP (concurrently running IIS6 with some ISAM-dlls, but w/o moodle).
If you are after good Moodle performance & tunability, WinXP/IIS aren't your best friends -- perhaps you could try with Apache2 on WinXP. Even better, take the plunge and do the Linux thing.
Distributing Server Load with Round-Robin DNS
Another way for freeing some heavy load to the moodle server.
Another way for freeing some heavy load to the moodle server.
Martin how do you compute my maxclients?
Given:
1G ram
40g hardisk
linux (fedora)
with mysql and php
what will be my maxclient and prefork and worker? by the how to make persistent connction in mysql what do i need to add in my.cnf?
Given:
1G ram
40g hardisk
linux (fedora)
with mysql and php
what will be my maxclient and prefork and worker? by the how to make persistent connction in mysql what do i need to add in my.cnf?
Don't use worker -- use prefork (there's a switch elsewhere in the config file). The formula for maxclients is in a posting of mine in this thread -- help yourself
There's a setting in seconds in my.cnf, don't remember the name. Read up on the mysql documentation on how to shorten the persistent connection timeouts.
There's a setting in seconds in my.cnf, don't remember the name. Read up on the mysql documentation on how to shorten the persistent connection timeouts.
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 150
MaxClients 24
MaxRequestsPerChild 1000
</IfModule>
Martin, I compute the maxclient is equal to 24, how about the maxrequestperchild and other number should i need to change these number?
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 150
MaxClients 24
MaxRequestsPerChild 1000
</IfModule>
Martin, I compute the maxclient is equal to 24, how about the maxrequestperchild and other number should i need to change these number?
Oh, sorry -- it's not that important to fiddle with the spareservers settings, so you're ok. Now that you have it like that, hit the homepage with a tool that gives you 24 of concurrency (try apache bench - aka "ab") while looking at the memory use in the server. It should _not_ use swap. Fiddle with maxclients up and down and retest.
If you're going to it it with many users, I'd suggest that you disable keepalives in the apache config, and use a php accelerator (I think you do anyway). Let us know how it goes!
Important: benchmark with ab or something more sophisticated before/after. You always need an indication of how things are changing in response to your fiddling.
If you're going to it it with many users, I'd suggest that you disable keepalives in the apache config, and use a php accelerator (I think you do anyway). Let us know how it goes!
Important: benchmark with ab or something more sophisticated before/after. You always need an indication of how things are changing in response to your fiddling.
Keepalive is now set to Off
Martin, this means that 24 user can login simutaneously?
How do I free httpd idle process?
Martin, this means that 24 user can login simutaneously?
How do I free httpd idle process?
... and how do I use swap memory if I used up my virtual memory?
Hmmm. Swap is another name for virtual memory ;)
Many users can login simultaneously. This is about 24 HTTP connections.
what i mean the hardisk as swap memory...
martin, we usually had 250 students login simutaneously, can my server now handle this amount of user?
Too complex a question. Only testing can tell.
When changing configs for performance, test before and after the changes. Beware of one thing though if you're using ab to test: check Moodle with a normal web browser while you're running the test with ab.
ab won't warn you if PHP is returning an error page (for instance the "database connection refused" page. I'm trying to fix that, but for the time being, it's an important caveat.
When changing configs for performance, test before and after the changes. Beware of one thing though if you're using ab to test: check Moodle with a normal web browser while you're running the test with ab.
ab won't warn you if PHP is returning an error page (for instance the "database connection refused" page. I'm trying to fix that, but for the time being, it's an important caveat.
Thanks martin...
Another way to accelerate the site is to configure the http accelerator...
http://www.squid-cache.org/Doc/FAQ/FAQ-20.html
or
http://www.vergenet.net/linux/redundant_linux_paper/talk/html/node10.html
Another way to accelerate the site is to configure the http accelerator...
http://www.squid-cache.org/Doc/FAQ/FAQ-20.html
or
http://www.vergenet.net/linux/redundant_linux_paper/talk/html/node10.html
How do my config.php looks like when I had configured my squid?
In using the port 80 for moodle and port 81 for squid...
I notice that files is not updating or unable to edit/add/delete resources and messages.
In using the port 80 for moodle and port 81 for squid...
I notice that files is not updating or unable to edit/add/delete resources and messages.