|
|
| Zeile 81: |
Zeile 81: |
|
| |
|
| [[Kategorie:MediaWiki/Verwaltung]] | | [[Kategorie:MediaWiki/Verwaltung]] |
|
| |
|
| |
| * Stellen Sie sicher, dass Ihrem Webserver und PHP genügend Arbeitsspeicher zugewiesen ist.
| |
| * Es gibt eine Vielzahl von Caching-Tools
| |
| ** die in Verbindung mit MediaWiki (und miteinander) verwendet werden können, wie Varnish und Memcached.
| |
|
| |
| Sie können alle Optionen für das Caching hier sehen:
| |
| * [https://www.mediawiki.org/wiki/Manual:Performance_tuning https://www.mediawiki.org/wiki/Manual:Performance_tuning ]
| |
|
| |
| * Die Verwendung von Nginx oder Lighttpd als Webserver anstelle von Apache kann die Leistung für stark frequentierte Websites erheblich verbessern.
| |
| To reduce MediaWiki CPU load, offload server processing by enabling robust '''PHP OPcache''', installing '''APCu/Memcached''' object caching, and blocking resource-intensive bot crawlers. These changes prevent your server from constantly re-rendering pages and recompiling scripts on every visit. [[https://www.mediawiki.org/wiki/Manual:Varnish_caching<nowiki> 1], </nowiki>[[mediawikiwiki:Manual:Performance_tuning|2]], [https://serverfault.com/questions/397482/need-help-trouble-shooting-high-cpu-usage-by-php-fpm 3]]
| |
|
| |
| 1. Enable PHP Caching (Essential)
| |
|
| |
| PHP natively recompiles code on every page request. Caching these scripts drastically reduces CPU usage. [[https://www.mediawiki.org/wiki/Manual:Varnish_caching<nowiki> 1], [</nowiki>https://www.mediawiki.org/wiki/Manual:Performance_tuning 2]]* '''OPcache:''' Ensure OPcache is enabled in your <code>php.ini</code> file. Set <code>opcache.enable=1</code> and allocate adequate memory (e.g., <code>opcache.memory_consumption=128</code>).
| |
|
| |
| * '''APCu:''' Install the APCu PHP extension for fast, local object caching. [[https://www.mediawiki.org/wiki/Manual:Performance_tuning/ca<nowiki> 1], </nowiki>[https://wiki.centos-webpanel.com/improve-website-performance 2], [https://www.mediawiki.org/wiki/Manual:Varnish_caching 3]]
| |
|
| |
| 2. Configure MediaWiki Object & Main Cache
| |
|
| |
| Stop MediaWiki from repeatedly hitting the database for frequently accessed data. [[https://hexshift.medium.com/step-by-step-guide-to-optimizing-mediawiki-performance-with-caching-and-profiling-391b5203d166 1]]* Open your <code>LocalSettings.php</code> file and add:
| |
|
| |
| php
| |
|
| |
| $wgMainCacheType = CACHE_ACCEL;
| |
|
| |
| $wgParserCacheType = CACHE_ACCEL;
| |
|
| |
| $wgSessionCacheType = CACHE_ACCEL;
| |
|
| |
| Verwende Code mit Vorsicht.
| |
|
| |
| [[https://www.mediawiki.org/wiki/Manual:$wgMainCacheType<nowiki> 1], </nowiki>[https://hexshift.medium.com/step-by-step-guide-to-optimizing-mediawiki-performance-with-caching-and-profiling-391b5203d166 2], [https://lists.wikimedia.org/hyperkitty/list/mediawiki-l@lists.wikimedia.org/thread/S7YWAMM6BHTZBOK7ZPQ2ZBKRSML42OPP/ 3]]
| |
|
| |
| 3. Optimize Bots & Crawlers
| |
|
| |
| Aggressive search engine bots can index dynamic pages (like <code>api.php</code> or <code>index.php?action=history</code>) and overwhelm your CPU. [[https://github.com/bitnami/charts/issues/3138<nowiki> 1], [</nowiki>https://serverfault.com/questions/397482/need-help-trouble-shooting-high-cpu-usage-by-php-fpm 2]]* Create or update a strict <code>robots.txt</code> file in your main directory to block non-canonical URLs and system pages.
| |
|
| |
| * Example rules: text User-agent: * Disallow: /wiki/Special: Disallow: /w/api.php Disallow: /w/index.php Verwende Code mit Vorsicht. [[https://serverfault.com/questions/397482/need-help-trouble-shooting-high-cpu-usage-by-php-fpm 1]]
| |
|
| |
| 4. Adjust Heavy Extensions
| |
|
| |
| Complex extensions like '''Semantic MediaWiki (SMW)''' can add significant server overhead during page loads. [[https://hexshift.medium.com/step-by-step-guide-to-optimizing-mediawiki-performance-with-caching-and-profiling-391b5203d166 1]]* If using SMW, enable '''query caching''' to prevent re-calculating complex semantic queries every visit. Add this to <code>LocalSettings.php</code>:
| |
|
| |
| php
| |
|
| |
| $smwgEnableCache = true;
| |
|
| |
| Verwende Code mit Vorsicht.
| |
|
| |
| 5. Disable Unnecessary Counters
| |
|
| |
| Tracking page views can spike CPU usage on busier sites. [<nowiki/>[[mediawikiwiki:Topic:Rncjbh4poqojjt9k|1]]]* If you do not need site statistics, you can disable the page counter by adding the following to <code>LocalSettings.php</code>:
| |
|
| |
| php
| |
|
| |
| $wgDisableCounters = true;
| |
|
| |
| Verwende Code mit Vorsicht.
| |
|
| |
| 6. Fine-Tune PHP-FPM / FastCGI
| |
|
| |
| If your PHP-FPM processes are consuming excessive CPU due to heavy traffic, limit how long each process runs before being recycled to clear memory. [[https://www.mediawiki.org/wiki/Topic:U1sl12b4w1gkbh2k<nowiki> 1], [</nowiki>https://serverfault.com/questions/397482/need-help-trouble-shooting-high-cpu-usage-by-php-fpm 2]]* In your <code>php-fpm.conf</code> or pool config, configure <code>pm.max_requests</code> to refresh processes (e.g., <code>pm.max_requests = 500</code>).
| |
|
| |
| For a more comprehensive guide on scaling, consult the official [[mediawikiwiki:Manual:Performance_tuning|MediaWiki Performance Tuning Manual]]. [<nowiki/>[[mediawikiwiki:Manual:Performance_tuning|1]]]
| |
|
| |
| If you would like, tell me more about your setup:* Are you using '''Apache or Nginx'''?
| |
|
| |
| * What '''extensions''' (like Semantic MediaWiki) are currently active? [[https://hexshift.medium.com/step-by-step-guide-to-optimizing-mediawiki-performance-with-caching-and-profiling-391b5203d166 1]]
| |
|
| |
|
| </noinclude> | | </noinclude> |