「パフォーマンス」の版間の差分

提供:MoodleDocs
移動先:案内検索
編集の要約なし
3行目: 3行目:
Moodleは、少ないユーザでも数千名のユーザでも快適に稼動させることができます。パフォーマンスに関係する要素は、基本的にどのPHPベースのデータベース主導型システムとも同じです。 あなたのサーバを最適化するには、「ユーザに関して多くの差がある点」に焦点を置いてください。例えば、相対的にみて、データベースにアクセスするユーザよりも閲覧するユーザが多い場合、ウェブサーバのパフォーマンスの改善を試みてください。
Moodleは、少ないユーザでも数千名のユーザでも快適に稼動させることができます。パフォーマンスに関係する要素は、基本的にどのPHPベースのデータベース主導型システムとも同じです。 あなたのサーバを最適化するには、「ユーザに関して多くの差がある点」に焦点を置いてください。例えば、相対的にみて、データベースにアクセスするユーザよりも閲覧するユーザが多い場合、ウェブサーバのパフォーマンスの改善を試みてください。


==ベンチマークの基準を取得する==
==ベンチマークのベースラインを取得する==


Before attempting any optimization, you should obtain a baseline benchmark of the component of the system you are trying to improve. For Linux try [http://lbs.sourceforge.net/ LBS] and for Windows use the Performance Monitor. Once you have quantitative data about how your system is performing currently, you'll be able to determine if the change you have made as has any real impact.
最適化を試みる前に、あなたが改善しようと考えるシステムコンポーネントに関するベンチマークのベースラインを取得してください。Linuxの場合、[http://lbs.sourceforge.net/ LBS]をお試しください。Windowsの場合、パフォーマンスモニターを使用してください。システムに関する現在のパフォーマンスの数値データを取得することにより、あなたの変更がどれだけ実際のインパクトを与えたのか測定することができるようになります。


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 eliminate swap file usage as much as you can. If your system starts swapping, this is a sign that you need more RAM.  
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 eliminate swap file usage as much as you can. If your system starts swapping, this is a sign that you need more RAM.  

2007年3月15日 (木) 22:11時点における版

作成中です - Mitsuhiro Yoshida 2007年3月14日 (水) 23:19 (CDT)

Moodleは、少ないユーザでも数千名のユーザでも快適に稼動させることができます。パフォーマンスに関係する要素は、基本的にどのPHPベースのデータベース主導型システムとも同じです。 あなたのサーバを最適化するには、「ユーザに関して多くの差がある点」に焦点を置いてください。例えば、相対的にみて、データベースにアクセスするユーザよりも閲覧するユーザが多い場合、ウェブサーバのパフォーマンスの改善を試みてください。

ベンチマークのベースラインを取得する

最適化を試みる前に、あなたが改善しようと考えるシステムコンポーネントに関するベンチマークのベースラインを取得してください。Linuxの場合、LBSをお試しください。Windowsの場合、パフォーマンスモニターを使用してください。システムに関する現在のパフォーマンスの数値データを取得することにより、あなたの変更がどれだけ実際のインパクトを与えたのか測定することができるようになります。

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 eliminate swap file usage as much as you can. If your system starts swapping, this is a sign that you need more RAM.

The optimization order preference is usually: primary storage (more RAM), secondary storage (faster hard disks/improved hard disk configuration), processor (more and faster).

スケーラビリティ (拡張性)

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.

ハードウェア設定

Note: The fastest and most effective change that you can make to improve performance is to increase the amount of RAM on your web server - get as much as possible (eg 4GB). Increasing primary memory will reduce the need for processes to swap to disk and will enable your server to handle more users.

  • Better performance is gained by obtaining the best processor capability you can, i.e. dual or dual core processors. A modern BIOS should allow you to enable hyperthreading, but check if this makes a difference to the overall performance of the processors by using a CPU benchmarking tool.
  • If you can afford them, use SCSI hard disks instead of SATA drives. SATA drives will increase your system's CPU utilization, whereas SCSI drives have their own integrated processors and come into their own when you have multiple drives. If you must have SATA drives, check that your motherboard and the drives themselves support NCQ (Native Command Queuing).
  • Purchase hard disks with a low seek time. This will improve the overall speed of your system, especially when accessing Moodle's reports.
  • Size your swap file correctly. The general advice is to set it to 4 x physical RAM.
  • Use a RAID disk system. Although there are many different RAID configurations you can create, the following generally works best:
    • install a hardware RAID controller (if you can)
    • the operating system and swap drive on one set of disks configured as RAID-1.
    • Moodle, Web server and Database server on another set of disks configured as RAID-5.
  • Use gigabit ethernet for improved latency and throughput. This is especially important when you have your webserver and database server separated out on different hosts.
  • Check the settings on your network card. You may get an improvement in performance by increasing the use of buffers and transmit/receive descriptors (balance this with processor and memory overheads) and off-loading TCP checksum calculation onto the card instead of the OS.

オペレーティングシステム

  • You can use Linux(recommended), Unix-based, Windows or Mac OS X for the server operating system. *nix operating systems generally require less memory than Mac OS X or Windows servers for doing the same task as the server is configured with just a shell interface. Additionally Linux does not have licensing fees attached, but can have a big learning curve if you're used to another operating system. If you have a large number of processors running SMP, you may also want to consider using a highly tuned OS such as Solaris.
  • Check your own OS and vendor specific instructions for optimization steps.
    • For Linux look at the Linux Performance Team site.
    • For Linux investigate the hdparm command, e.g. hdparm -m16 -d1 can be used to enable read/write on multiple sectors and DMA. Mount disks with the async and noatime options.
    • For Windows set the sever to be optimized for network applications (Control Panel, Network Connections, LAN connection, Properties, File & Printer Sharing for Microsoft Networks, Properties, Optimization). You can also search the Microsoft TechNet site for optimization documents.

ウェブサーバパフォーマンス

  • あなたのウェブサーバの「RAM」の容量はパフォーマンスに関する重要な要素です - 可能な限り多く設置してください (例 4GB)。
  • LinuxまたはUnixがサーバに対するMoodle推奨「オペレーティングシステム」です。LinuxやUnixは、高負荷時にMac OSXやWindowsサーバよりも快適に動作します。
  • CPUの負荷を軽減するため、Turck MMCacheまたはThe ionCube PHP Acceleratorのような、PHP acceleratorの利用を強くお勧めします。
  • PHPをApacheモジュールとしてインストールすると、パフォーマンスは (CGIよりも) 良くなります。
  • Unix/Linuxシステムでは、(PHPベースのzipライブラリよりも) システムのzip/unzipコマンドの使用を許可することで、パフォーマンスが大きく改善されます - 管理/設定/詳細設定へアクセスして、適切な実行ファイルのパスを入力してください。(同様に、duのパスを入れることで、Moodleのディレクトリコンテンツのリスティングスピードが改善されます。)
  • セキュアウェブコネクション (https) を使用することで、ウェブサーバおよびクライアントに高い負荷がかかります - 特に効果的なキャッシングが使用されないため、ファイルのリクエスト数が劇的に増加する場合があることに注意してください。この理由から、すべてのMoodleページにhttpsを使用することは、お勧めできません。Moodle詳細設定ページにて、ログインページのみhttpsを利用できるよう設定できます。
  • メモリの使用量が大幅に軽減されるため、Apacheの代わりに、軽いウェブサーバ lighttpdfastCGIの利用でパフォーマンスを良くすることができます。1つのapacheプロセスは、lighttpdfastCGIのすべてのプロセスより多くのメモリを必要とします。管理者が作業に時間を必要とするため、あなたが十分なハードウェアを用意できる場合、これは最良の方法ではないと思われます。
  • httpd.confのMaxRequestsPerChildを20-30くらいに下げることを考えてください。(この値を低く設定し過ぎた場合、パフォーマンスの向上よりシステムのオーバーヘッドが増すことになります)。 php.iniのmemory_limitを少なくとも16Mに下げることも考えてください。 (Rory Allford氏による推奨)
  • --- (要翻訳) -------------------------------------
  • PHP performance
    • You are strongly recommended to use a PHP accelerator to ease CPU load, such as APC (recommended), PHPA, Xcache or eAccelerator. (Take care to choose a PHP accelerator that is known to work well with your version of PHP and note that Turck MMCache is no longer maintained and can cause failures with PHP 5). Put the cached PHP pages on a TMPFS filesystem.
    • Performance of PHP is better when installed as an Apache/IIS ISAPI module (rather than a CGI).
    • Also check the memory_limit in php.ini, reduce it to 16M for Moodle version earlier than 1.7 (See this forum discussion). For Moodle 1.7 or later, it is recommended that the value of memory_limit should be 32M.
  • Apache performance
    • 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.
    • 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).
    • For a heavily loaded server, consider lowering the KeepAliveTimeout to between 2 and 5. The default is 15 (seconds) - the higher the value the more server processes will be kept waiting for possibly idle connections.
    • 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.
  • IIS performance - all alter this location in the registry:
HKLM\SYSTEM\CurrentControlSet\Services\Inetinfo\Parameters\
  • The equivalent to KeepAliveTimeout is ListenBackLog (IIS - registry location is HKLM\ SYSTEM\ CurrentControlSet\ Services\ Inetinfo\ Parameters). Set this to between 2 to 5.
  • Change the MemCacheSize value to adjust the amount of memory (Mb) that IIS will use for its file cache (50% of available memory by default).
  • Change the MaxCachedFileSize to adjust the maximum size of a file cached in the file cache in bytes. Default is 262,144 (256K).
  • Create a new DWORD called ObjectCacheTTL to change the length of time (in milliseconds) that objects in the cache are held in memory. Default is 30,000 milliseconds (30 seconds).

データベースパフォーマンス

Moodle contains a script which will display some key database performance statistics from the ADOdb performance monitor. Run the script in your browser as in the following example:

http://www.mymoodle.com/admin/dbperformance.php

Use the data displayed as a guide to tune and improve the performance of your database server.

MySQLパフォーマンス

The following are MySQL specific settings which can be adjusted for better performance in your my.cnf (my.ini in Windows). To see the current values use these commands

SHOW STATUS;
SHOW VARIABLES; 

Important: You must make backups of your database before attempting to change any MySQL server configuration. After any change to the my.cnf, restart mysqld.

  • Enable the query cache with query_cache_type = 1. For most Moodle installs, set the query_cache_size to 36M and query_cache_min_res_unit to 2K. The query cache will improve performance if you are doing few updates on the database.
  • Set the table cache correctly. For Moodle 1.6 set table_cache = 159, and for Moodle 1.7 set table_cache = 170. Note that this figure will change depending on the number of modules and plugins you have installed. Find the number for your server by executing the mysql statement below. Look at the number of rows printed and set table_cache to this value.
mysql>SELECT table_name FROM information_schema.tables WHERE table_schema='yourmoodledbname';
  • Set the thread cache correctly. Adjust the value so that your thread cache utilization is as close to 100% as possible by this formula:
thread cache utilization (%) = (threads_created / connections) * 100
  • 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) and in Moodle 1.6 or later (without any additional modules and plugins), the recommendation for this value is key_buffer_size = 32M. Ideally you want the database to be reading once from the disk for every 100 requests so monitor that the value is suitable for your install by adjusting the value of key_buffer_size so that the following formulas are true:
key_read / key_read_requests < 0.01
key_write / key_write_requests <= 1.0
  • Set the maximum number of connections so that your users will not see a "Too many connections" message. Be careful that this may have an impact on the total memory used. MySQL connections usually last for milliseconds, so it is unusual even for a heavily loaded server for this value to be over 200.
  • Manage high burst activity. If your Moodle install uses a lot of quizzes and you are experiencing performance problems (check by monitoring the value of threads_connected - it should not be rising) consider increasing the value of back_log.
  • Optimize your tables weekly and after upgrading Moodle. It is good practice to also optimize your tables after performing a large data deletion exercise, e.g. at the end of your semester or academic year. This will ensure that index files are up to date. Backup your database first and then use:
mysql>CHECK TABLE mdl_tablename;
mysql>OPTIMIZE TABLE mdl_tablename;
The common tables in Moodle to check are mdl_course_sections, mdl_forum_posts, mdl_log and mdl_sessions (if using dbsessions). Any errors need to be corrected using REPAIR TABLE (see the MySQL manual).
  • Maintain the key distribution. Every month or so it is a good idea to stop the mysql server and run these myisamchk commands.
#myisamchk -a -S /pathtomysql/data/moodledir/*.MYI
Warning: You must stop the mysql database process (mysqld) before running any myisamchk command. If you do not, you risk data loss.
  • Reduce the number of temporary tables saved to disk. Check this with the created_tmp_disk_tables value. If this is relatively large (>5%) increase tmp_table_size until you see a reduction. Note that this will have an impact on RAM usage.
  • Moodle's tables are in the MyISAM format, so turn InnoDB off as there is no performance gain. If you must use InnoDB, you'll have to convert all of Moodle's tables. To do this run the innodb script:
http://www.mymoodle.com/admin/innodb.php

Other database performance links

Moodle管理設定

  • Enable the language cache.
  • Large log files can cause overall performance to degrade over time. If you observe that the site has gradually got slower loading pages in the browser, reduce your Log life time setting (Admin/Configuration/Variables/Maintenance).
  • In Moodle 1.7 or later, enable the record cache. This will act as a primary cache and improve database access performance.
  • Performance can be greatly improved by allowing Moodle 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.
  • 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.
  • Enable the text cache but 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).
  • If there are performance problems loading course pages, check the Resource module settings. The setting resource_filterexternalpages is known to slow-down course pages and should be set to 'No' for better performance.
  • Check your forum settings. To improve performance set forum_trackreadposts = No and forum_usermarksread = Yes (this will impact on the convenience of your users' forum experience). Also consider setting the time of the day when old posts are cleared from the read table (forum_cleanreadtime) to when your site is less busy.

各Moodleモジュールのパフォーマンス

Moodleの活動モジュールフィルタおよび他のプラグインは有効/無効にすることができます。不要な場合 (必須ではありませんが)、必要に応じていくつかの機能 (チャット等) を無効にしてください。各モジュールに関するノート:

  • チャットモジュールは、メインサーバに対して頻繁にHTTPリクエストする点において、大食いだと言われています。管理 >> 設定 >> モジュール管理 >> チャット で、chat_normal_updatemodeを「Streame」にするか、chat_methodを「Chatサーバデーモン」にすることでサーバに対する負荷を軽減することができます。
  • 55名の学生が同時に小テストを使用する場合のパフォーマンスに関する報告 - 英文
  • Moodleのcronタスクは、スクリプトcron.phpを呼ぶことで動作します。このスクリプトが、HTTP経由で呼ばれた場合 (例 wgetまたはcurlを使用)、大規模なMoodleサイトでは大量のメモリを消費します。phpコマンドを使用して直接呼ばれた場合 (例 php -f /path/to/moodle/directory/admin/cron.php)、効率は大幅に改善されます。
  • 多くのフィルタを有効にする場合、サーバの負荷 (特にスペックの低いサーバ) に重大な影響を及ぼします。有効にされているフィルタの数は、あなたのサイトのレスポンスに関して直接影響を、すなわち各ページの表示に要する時間に関して影響を及ぼします。パフォーマンスを上げるため、管理 >> 設定 >> フィルタ の「テキストキャッシュ保存時間」を「No」以外に設定して、特に必要がない場合は「すべての文字をフィルタする」を「No」にしてください。設定が疑わしい場合、パフォーマンスのプロファイリングを行って、あなたの変更内容がプロセスタイムにどのように影響するのか確認してください。

関連情報