Book Image

Moodle Administration

By : Moodle Trust, Alex Büchner
Book Image

Moodle Administration

By: Moodle Trust, Alex Büchner

Overview of this book

Table of Contents (22 chapters)
Moodle Administration
Credits
About the Author
About the Reviewer
Preface
Index

System


Some of the system-related information collated in this section has been derived from the performance section on MoodleDocs http://docs.moodle.org/en/Performance and also http://docs.moodle.org/en/Installing_AMP.

Operating System

OS1 Server dedicated to Moodle (Chapter 3)

Moodle performs best when run on a dedicated server, that is, no other applications are running in parallel on the same system. Examples that should be avoided are mail servers and other web servers.

Uninstall any software that is not required and turn off any services that are not needed.

OS2 Non-Unix Operating System (Chapters 2 and 3)

Moodle has been developed and optimized for a LAMP platform (Linux, Apache, MySQL, and PHP/Perl). It, therefore, runs the most stable in such an environment. When run on a Windows server, approximately twice the hardware resources are required to achieve the same performance of a Moodle system.

Invest in a Unix/Linux server or sign up with a dedicated Moodle host that uses Unix as the operating system.

OS3 Unicode support (Chapters 2 and 8)

Moodle supports multi-language character sets and, therefore, requires necessary Unicode libraries to be installed on operating system level.

Install Unicode libraries on your system. Apply the Moodle Unicode migration script at: http://moodle.yourorg.com/admin/utfdbmigrate.html

OS4 Optimize Network Applications (Chapter 2)

A Windows server should be set to be optimized for network applications. This setting is available at:

Control Panel | Network Connections | LAN Connection | Properties | File and Print Sharing for Microsoft Networks | Properties | Optimization

Database

DB1 MySQL Version (Chapters 2 and 3)

Moodle requires MySQL version 4.1.16.

Upgrade your database system MySQL to version 4.1.16 or greater.

DB2 Query caching enabled

The query cache stores query statements, which increases performance when the same query is run multiple times. Keep the following things in mind:

  • Set query cache using the query_cache_size parameter in my.cnf to 36M

  • Set the query_cache_type parameter in my.cnf to 1.

  • Set the query_cache_min_res_unit parameter in my.cnf to 2K.

DB3 Table caching enabled

The table cache stores table-related information for re-usage.

Set table cache using the table_cache parameter in my.cnf to a minimum of 256 (Moodle 1.6) and 512 (for all greater versions), respectively.

DB4 Thread caching enabled

The thread cache keeps connections alive instead of closing them, which costs time and allows the re-usage at a later stage. This is not to be confused with connection-pooling.

Adjust the value in my.cnf so that the thread cache utilization is as close to 100% as possible (thread cache utilization (%) = (threads_created /connections) * 100).

DB5 Enabled key buffering

The key buffer can improve the access speed to Moodle's SELECT queries. The correct size depends on the size of the index files (.myi).

Set the key buffer size using the key_buffer_size parameter in my.cnf to 32M, and a higher value if additional modules and plug-ins are installed.

DB6 Turn off InnoDB

"InnoDB is a storage engine which provides MySQL with a transaction-safe (ACID compliant) storage engine that has commit, rollback, and crash recovery capabilities. InnoDB does locking on the row level and also provides an Oracle-style consistent non-locking read in SELECT statements. These features increase multi-user concurrency and performance.

Moodle tables are in the MyISAM format, so InnoDB can be turned off as there is no performance gain."

To turn off InnoDB in MySQL, please consult: http://dev.mysql.com/doc/refman/5.0/en/innodb-configuration.html.

If you have to use InnoDB, all tables that are used by Moodle have to be converted from the current MyISAM format using the http://moodle.yourorg.com/admin/innodb.php

DB7 Cache hit ratio >90%

The MyISAM cache hit ratio should be at least 90%. A value of less than 90% is a strong indication of the fact that the database isn't performing to its fullest.

Adjust caching parameters until the ratio reaches a minimum of 90%.

DB8 Run XMLDB Test

XMLDB is Moodle's database abstraction layer, that is, the library of code that lets Moodle interact with and access the database. It provides a test feature that shows any anomalies in the database structure.

Check errors and fix accordingly.

DB9 Database Index Test

A search for potential missing indexes in your Moodle server can be carried out.

Check errors and fix accordingly.

DB10 Database Bigints Test

A search for potential wrong integer fields in your Moodle server can be carried out.

Check errors and fix accordingly.

DB11 Database and all tables have to be Unicode (Chapters 2 and 8)

The database and all the used tables have to be Unicode (collation utf8_unicode_ci or utf8_general_ci, for example).

Check all your tables and make sure none are in non-Unicode collation order such as latin1.

If the entire database is still in non-Unicode format, apply the Moodle Unicode migration script at http://moodle.yourorg.com/admin/utfdbmigrate.html.

PHP

PHP1 PHP Accelerator installed (Chapter 3)

A PHP accelerator boosts the performance of PHP code by caching compiled bytecode from PHP scripts. Moodle uses PHP as underlying programming language and a PHP accelerator is vital to achieve acceptable performance.

A PHP accelerator should be installed. Recommended optimizers are APC or Zend.

PHP2 PHP Version (Chapter 2)

Moodle uses PHP as underlying programming language. Depending on which version of PHP is used, it requires a minimum release to work properly.

  • Version 4.3.0 is required if PHP4 is used.

  • Version 5.1.0 is required if PHP5 is used.

  • Version 5.2.0 is required for forthcoming version Moodle 2.0.

PHP3 PHP extension iconv (Chapter 2)

The iconv PHP extension provides functionality to convert characters from one character set to another. It is required in Moodle.

Install the PHP iconv extension on your system.

PHP4 PHP extension mbstring (Chapter 2)

The mbstring PHP extension provides multibyte specific string functions and encodings. It is required for Moodle Unicode support.

Install the PHP mbstring extension on your system.

PHP5 PHP extension curl (Chapters 2 and 14)

The curl PHP extension provides functionality to securely fetch data from remote sites. It is required for Moodle networking features.

Install the PHP curl extension on your system.

PHP6 PHP extension openssl (Chapters 2 and 14)

The openssl PHP extension provides functionality to employ asynchronous encryption techniques (PKI encryption). It is required for Moodle networking features.

Install the PHP openssl extension on your system.

PHP7 PHP extension tokenizer (Chapter 2)

The tokenizer PHP extension provides an interface to the PHP tokenizer embedded in the Zend engine. It is required in Moodle for PHP acceleration.

Install the PHP tokenizer extension on your system.

PHP8 Configure PHP as Apache / IIS ISAPI module

The performance of PHP is significantly better when installed as an Apache/IIS ISAPI module, rather than a CGI binary.

Install PHP as Apache module on a Unix server. It is best to uninstall PHP as CGI first.

Install PHP as Apache module on a Windows server. It is best to uninstall PHP as CGI first.

If you have to install PHP as CGI, enable the fastcgi

PHP9 memory_limit set to appropriate value (Chapter 11)

The memory limit specified has an impact on the performance of PHP code.

Set the memory limit to 40M using the memory_limit parameter in php.

Web Server

WS1 Apache Version

Apache 2 has an improved memory model, which reduces memory usage and should be used for any Moodle system.

Install Apache 2 on your server.

WS2 Number of Apache modules

Reducing the number of modules that Apache loads to the minimum necessary will reduce the memory needed, which should be taken care of while loading modules in the httpd.conf file.

WS3 MaxClients Directive

The MaxClients parameter sets the limit of maximum simultaneous requests that can be supported by the server (maximum number of spawned child processes). It shouldn't be set too low, otherwise an ever-increasing number of connections are deferred to the queue and they eventually time-out while the server resources are left unused. Setting this too high, on the other hand, will cause the server to start swapping. This will cause the response time to degrade drastically.

MaxClients = Total RAM dedicated to the web server / Max child process size

Set the MaxClients directive in httpd.conf to its appropriate value.

WS4 MaxRequestsPerChild Directive

The MaxRequestsPerChild parameter sets the limit on the number of requests that an individual child server process will handle. After MaxRequestsPerChild requests, the child process will die and will never expire if set to its default value of 0.

Set the MaxRequestsPerChild directive in httpd.conf

WS5 KeepAlive and KeepAliveTimeout Directives

The KeepAlive directive allows multiple requests to be sent over the same TCP connection. This is particularly useful while serving image-rich HTML pages. If KeepAlive is set to Off, then for each image a separate TCP connection has to be made. Overhead, due to the establishment of a TCP connection, can be eliminated by turning On KeepAlive.

KeepAliveTimeout determines how long to wait for the next request. It is recommended to set this to a value between 2 and 5 seconds. If it is set too high, child processes are tied up waiting for the client when they could be used for serving new clients.

Set the KeepAlive directive in httpd.conf to On.

Set the KeepAliveTimeout directive in httpd.conf to a value between 20 and 30.

WS6 DirectoryIndex Directive

The DirectoryIndex parameter sets the list of resources to look for when the client requests an index of the directory by specifying a / at the end of a directory name. If set incorrectly, a time-consuming content negotiation will occur.

Set the DirectoryIndex directive in httpd.conf to index.php index.html index.htm.

WS7 ExtendedStatus Directive

The ExtendedStatus parameter controls whether the server keeps track of extended status information for each request. This is only useful if the status module is enabled on the server. This is only required while development work is carried out.

Set the ExtendedStatus directive in httpd.conf to off

WS8 HostnameLookups Directive

The HostnameLookups parameter enables DNS lookups so that host names can be logged. Lookups are expensive and should be avoided if possible.

Set the HostnameLookups directive in httpd.conf to off.

WS9 TimeOut Directive

The TimeOut parameter defines the amount of time Apache will wait from the total amount of time it takes to receive a GET request, the amount of time between receipt of TCP packets on a POST or PUT request, and the amount of time between ACKs on transmissions of TCP packets in responses.

Unless the server is used for other web applications, set the TimeOut directive in httpd.conf to a value between 30 and 60.

WS10 Option Directive

Avoid Option Multiview as this performs a directory scan, which can be I/O expensive.

Set the Option directive in httpd.conf to All.

WS11 AcceptPathInfo Directive

The AcceptPathInfo parameter allows scripts to be passed as arguments that are essential to allow relative links between your resources.

Set the AcceptPathInfo directive in httpd.conf to On.

WS12 Caching

Apache can be told to load pages faster by specifying that the browser should cache some page elements such as images, and reuse them from local memory rather than reload them every time a page is requested.

Configure Apache so that everything stays in the browser cache except HTML and XML content. The procedure differs for various operating systems.