Performance recommendations: Difference between revisions

From MoodleDocs
(ja link)
m (Updating of text)
Line 3: Line 3:
Large sites usually separate the web server and database onto separate servers, although for smaller installations this is typically not necessary.
Large sites usually separate the web server and database onto separate servers, although for smaller installations this is typically not necessary.


It is possible to load-balance a Moodle installation, for example by using more than one webserver. The separate webservers should query the same database and refer to the same filestore area, but otherwise the separation of the application layers is complete enough to make this kind of clustering feasible. Similarly, the database could be a cluster of servers (e.g. a MySQL cluster).
It is possible to load-balance a Moodle installation, for example by using more than one webserver. The separate webservers should query the same database and refer to the same filestore area, but otherwise the separation of the application layers is complete enough to make this kind of clustering feasible. Similarly, the database could be a cluster of servers (e.g. a MySQL cluster), but this is not an easy task and you should seek expert support, e.g. from a Moodle Partner.


:::The above comment makes it sound easy to run a database cluster. It is not. It is easy to run the webservers in cluster with LVM and other solutions. The only "easy" cluster database is MySQL Cluster and there are several issues with it. --[[User:Martin Langhoff|Martin Langhoff]] 18:53, 31 August 2006 (CDT)
The overall aim of adjustments to improve performance is to use RAM (cacheing) and to reduce disk-based activity. It is especially important to try to reduce swap file usage as much as you can.


==Web server performance==
==Web server performance==


* The amount of '''RAM''' on your web server is the strongest factor in performance - get as much as possible (eg 4GB).
* The amount of '''RAM''' on your web server is the strongest factor in performance - get as much as possible (eg 4GB).
* Linux or Unix is the recommended '''operating system''' for the server. They perform much better than Mac OSX or Windows servers at high loads.
* Linux or Unix is recommended for the server '''operating system'''. They require less memory than Mac OS X or Windows servers for doing the same task.
* You are strongly recommended to use a '''PHP accelerator''' to ease CPU load, such as Turck MMCache, PHPA or eAccelerator. (Take care to choose a PHP accelerator that is known to work well with your version of PHP etc.)
* You are strongly recommended to use a '''PHP accelerator''' to ease CPU load, such as Turck MMCache, APC, PHPA or eAccelerator. (Take care to choose a PHP accelerator that is known to work well with your version of PHP etc.)
* Performance of PHP is better when installed as an Apache module (rather than a CGI).
* Performance of PHP is better when installed as an Apache module (rather than a CGI).
* On a Unix/Linux system, performance can be greatly improved by allowing the webserver to use the system '''zip/unzip''' commands (rather than PHP-based zip libraries) - visit Admin/Configure/Variables and enter the path to the relevant executables. (Similarly, filling in the path to '''du''' will improve Moodle's speed at listing directory contents.)
* Performance can be greatly improved by allowing the webserver to use the system '''zip/unzip''' commands (rather than PHP-based zip libraries) - visit Admin/Configure/Variables and enter the path to the relevant executables. (Similarly, filling in the path to '''du''' will improve Moodle's speed at listing directory contents.)
* Note that using '''secure web connections''' ('''https''' rather than '''http''') carries a higher processing burden, both for the webserver and the client - particularly because cacheing cannot be used as effectively, so the number of file requests is likely to increase dramatically. For this reason using https for all Moodle pages is not recommended. You can enable https just for the login screen, simply from Moodle's config page.
* Note that using '''secure web connections''' ('''https''' rather than '''http''') carries a higher processing burden, both for the webserver and the client - particularly because cacheing cannot be used as effectively, so the number of file requests is likely to increase dramatically. For this reason using https for all Moodle pages is not recommended. You can enable https just for the login screen, simply from Moodle's config page.
* You can increase performance by using the light-weight webserver [http://www.lighttpd.org/ lighttpd] in combination with PHP in fastCGI-mode instead of Apache, due to much lower memory consumption. One single apache process requires more RAM than the whole lighttpd with all of its fastCGI-processes together. Note that this may not be a good solution if you can afford lots of hardware power, because administration takes a little more time.
* Consider reducing the '''number of modules''' that Apache loads in the httpd.conf file to the minumum necessary to reduce the memory needed. Also, use the latest version of Apache 2, which reduces memory usage further.
* Consider lowering MaxRequestsPerChild in httpd.conf to as low as 20-30 (if you set it any lower the overhead of forking begins to outweigh the benefits). Also check the memory_limit in php.ini, reduce it to at least 16M. ([http://moodle.org/mod/forum/discuss.php?d=39656 Suggested by Rory Allford])
* Alternatively, you can increase web server performance by using the '''light-weight webserver''' [http://www.lighttpd.org/ lighttpd] in combination with PHP in fastCGI-mode instead of Apache. Lighttpd has a lower memory consumption than Apache. One single apache process requires more RAM than the whole lighttpd with all of its fastCGI-processes together. Note that Lighttpd is relatively difficult to configure and administration takes a more time.
* For Unix/Linux systems, consider lowering '''MaxRequestsPerChild''' in httpd.conf to as low as 20-30 (if you set it any lower the overhead of forking begins to outweigh the benefits).  
* Also check the '''memory_limit''' in php.ini, reduce it to 16M for Moodle version earlier than 1.7. ([http://moodle.org/mod/forum/discuss.php?d=39656 Suggested by Rory Allford]). For Moodle 1.7 or later, memory_limit should be 32M.


==Database performance==
==Database performance==


* In Moodle 1.7 or later, enable the '''record cache'''. This will act as a primary cache and improve database access performance.
* [[Arguments in favour of PostgreSQL]]
* [[Arguments in favour of PostgreSQL]]
* [http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html Tuning MySQL parameters] (advice from the MySQL manual)
* [http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html Tuning MySQL parameters] (advice from the MySQL manual)
Line 28: Line 31:


* The '''Chat''' module is [http://moodle.org/mod/forum/discuss.php?d=37979&parent=175079 said] to be a hog in terms of frequent HTTP requests to the main server. This can be reduced by setting the module to use ''Streamed'' updates, or, if you're using a Unix-based webserver, by running the chat in daemon mode.
* The '''Chat''' module is [http://moodle.org/mod/forum/discuss.php?d=37979&parent=175079 said] to be a hog in terms of frequent HTTP requests to the main server. This can be reduced by setting the module to use ''Streamed'' updates, or, if you're using a Unix-based webserver, by running the chat in daemon mode.
* [http://moodle.org/mod/forum/discuss.php?d=25616&parent=120770 Brief report on performance for 55 students simultaneously using '''Quiz''']
* The '''quiz''' activity is known to stretch database performance. Try to optimise your database server by tuning. See [http://moodle.org/mod/forum/discuss.php?d=25616&parent=120770 for a brief report on performance for 55 students simultaneously using quizzes]
* The Moodle '''cron''' task is triggered by calling the script ''cron.php''. If this is called over HTTP (e.g. using wget or curl) it can take a large amount of memory on large installations. If it is called by directly invoking the php command (e.g. ''php -f /path/to/moodle/directory/admin/cron.php'') efficiency can be much improved.
* The Moodle '''Cron''' task is triggered by calling the script ''cron.php''. If this is called over HTTP (e.g. using wget or curl) it can take a large amount of memory on large installations. If it is called by directly invoking the php command (e.g. ''php -f /path/to/moodle/directory/admin/cron.php'') efficiency can be much improved.
* Having too many filters active can have serious effects on server load, especially on lower-end systems. The number of active filters has a direct effect on the perceived latency of your site; that is the time taken for each page impression. For best performance, leave the text cache enabled and do not "Filter all strings" unless you have a specific need. If in doubt [[Performance profiling|profile the performance]], and see how your changes affect the processing time.
* Check your '''filters'''. Having too many filters active can have serious effects on server load, especially on lower-end systems. The number of active filters has a direct effect on the perceived latency of your site; that is the time taken for each page impression. For best performance, leave the text cache enabled and do not "Filter all strings" unless you have a specific need. If in doubt [[Performance profiling|profile the performance]], and see how your changes affect the processing time.
* Check your Anti Virus measures on the ServerSome "on-Demand" scanners can affect performance by scanning page content (word , ppt files etc...).
* Check your '''anti-virus''' measures on the serverAlthough they are useful for preventing security holes being exploited, some "On-Demand" scanners can affect performance by scanning page content (word, ppt files etc).


==See also==
==See also==

Revision as of 12:57, 1 January 2007

Moodle can be made to perform very well, at small usage levels or scaling up to many thousands of users. The factors involved in performance are basically the same as for any PHP-based database-driven system, and Moodle's design (with clear separation of application layers) allows for strongly scalable setups. (Please check the list of large Moodle installations.)

Large sites usually separate the web server and database onto separate servers, although for smaller installations this is typically not necessary.

It is possible to load-balance a Moodle installation, for example by using more than one webserver. The separate webservers should query the same database and refer to the same filestore area, but otherwise the separation of the application layers is complete enough to make this kind of clustering feasible. Similarly, the database could be a cluster of servers (e.g. a MySQL cluster), but this is not an easy task and you should seek expert support, e.g. from a Moodle Partner.

The overall aim of adjustments to improve performance is to use RAM (cacheing) and to reduce disk-based activity. It is especially important to try to reduce swap file usage as much as you can.

Web server performance

  • The amount of RAM on your web server is the strongest factor in performance - get as much as possible (eg 4GB).
  • Linux or Unix is recommended for the server operating system. They require less memory than Mac OS X or Windows servers for doing the same task.
  • You are strongly recommended to use a PHP accelerator to ease CPU load, such as Turck MMCache, APC, PHPA or eAccelerator. (Take care to choose a PHP accelerator that is known to work well with your version of PHP etc.)
  • Performance of PHP is better when installed as an Apache module (rather than a CGI).
  • Performance can be greatly improved by allowing the webserver to use the system zip/unzip commands (rather than PHP-based zip libraries) - visit Admin/Configure/Variables and enter the path to the relevant executables. (Similarly, filling in the path to du will improve Moodle's speed at listing directory contents.)
  • Note that using secure web connections (https rather than http) carries a higher processing burden, both for the webserver and the client - particularly because cacheing cannot be used as effectively, so the number of file requests is likely to increase dramatically. For this reason using https for all Moodle pages is not recommended. You can enable https just for the login screen, simply from Moodle's config page.
  • Consider reducing the number of modules that Apache loads in the httpd.conf file to the minumum necessary to reduce the memory needed. Also, use the latest version of Apache 2, which reduces memory usage further.
  • Alternatively, you can increase web server performance by using the light-weight webserver lighttpd in combination with PHP in fastCGI-mode instead of Apache. Lighttpd has a lower memory consumption than Apache. One single apache process requires more RAM than the whole lighttpd with all of its fastCGI-processes together. Note that Lighttpd is relatively difficult to configure and administration takes a more time.
  • For Unix/Linux systems, consider lowering MaxRequestsPerChild in httpd.conf to as low as 20-30 (if you set it any lower the overhead of forking begins to outweigh the benefits).
  • Also check the memory_limit in php.ini, reduce it to 16M for Moodle version earlier than 1.7. (Suggested by Rory Allford). For Moodle 1.7 or later, memory_limit should be 32M.

Database performance

Performance of different Moodle modules

Moodle's activity modules, filters, and other plugins can be activated/deactivated. If necessary, you may wish to deactivate some features (such as chat) if not required - but this isn't necessary. Some notes on the performance of certain modules:

  • The Chat module is said to be a hog in terms of frequent HTTP requests to the main server. This can be reduced by setting the module to use Streamed updates, or, if you're using a Unix-based webserver, by running the chat in daemon mode.
  • The quiz activity is known to stretch database performance. Try to optimise your database server by tuning. See for a brief report on performance for 55 students simultaneously using quizzes
  • The Moodle Cron task is triggered by calling the script cron.php. If this is called over HTTP (e.g. using wget or curl) it can take a large amount of memory on large installations. If it is called by directly invoking the php command (e.g. php -f /path/to/moodle/directory/admin/cron.php) efficiency can be much improved.
  • Check your filters. Having too many filters active can have serious effects on server load, especially on lower-end systems. The number of active filters has a direct effect on the perceived latency of your site; that is the time taken for each page impression. For best performance, leave the text cache enabled and do not "Filter all strings" unless you have a specific need. If in doubt profile the performance, and see how your changes affect the processing time.
  • Check your anti-virus measures on the server. Although they are useful for preventing security holes being exploited, some "On-Demand" scanners can affect performance by scanning page content (word, ppt files etc).

See also