Page MenuHomeMiraheze

Cache frequently accessed files on MediaWiki servers
Open, NormalPublic

Description

Split from T5222#132534. MediaWiki performs countless lookups on the disk: the .cdb files for localisation and various .json files for ManageWiki. These files live on slower, spinning disk storage, yet these files are requested on every hit. By caching those files into memory, we can reduce the i/o on these servers and not waste time waiting for the files to be retrieved, hence improving our response times (especially the 95+th percentile responses).

Event Timeline

Southparkfan triaged this task as Normal priority.Jan 23 2021, 23:15
Southparkfan created this task.
southparkfan@mw4:~$ sort fatrace.txt | uniq -c | sort -nr | head -50
  51899 /srv/mediawiki/w/cache/l10n/l10n_cache-en.cdb
   4187 /srv/mediawiki/w/cache/databases.json
   3517 /srv/mediawiki/w/cache/l10n/l10n_cache-zh-cn.cdb
   3391 /etc/hosts
   3248 /etc/ssl/certs/Sectigo.crt
   2578 /srv/mediawiki/w/cache/l10n/l10n_cache-it.cdb
   1411 /home/southparkfan/fatrace.txt
    869 /srv/mediawiki/w/cache/l10n/l10n_cache-zh-hant.cdb
    775 /usr/share/ca-certificates/mozilla/DigiCert_High_Assurance_EV_Root_CA.crt
    748 /srv/mediawiki/w/cache/deleted.json
    705 /srv/mediawiki/w/cache/l10n/l10n_cache-ja.cdb
    603 /usr/share/zoneinfo/UCT
    527 /srv/mediawiki/w/cache/l10n/l10n_cache-zh.cdb
    419 /srv/mediawiki/w/cache/l10n/l10n_cache-es.cdb
    380 /srv/mediawiki/w/cache/l10n/l10n_cache-nl.cdb
    303 /srv/mediawiki/w/extensions/Echo/extension.json
    298 /srv/mediawiki/w/cache/l10n/l10n_cache-zh-tw.cdb
    292 /srv/mediawiki/w/cache/l10n/l10n_cache-ko.cdb
    291 /srv/mediawiki/w/extensions/AbuseFilter/extension.json
    290 /srv/mediawiki/w/extensions/CentralNotice/extension.json
    273 /srv/mediawiki/w/skins/Vector/skin.json
    271 /srv/mediawiki/w/skins/MonoBook/skin.json
    269 /srv/mediawiki/w/extensions/CheckUser/extension.json
    266 /srv/mediawiki/w/extensions/CreateWiki/extension.json
    265 /srv/mediawiki/w/skins/Modern/skin.json
    261 /srv/mediawiki/w/skins/CologneBlue/skin.json
    258 /srv/mediawiki/w/extensions/ConfirmEdit/extension.json
    257 /srv/mediawiki/w/skins/Timeless/skin.json
    257 /srv/mediawiki/w/extensions/AntiSpoof/extension.json
    255 /srv/mediawiki/w/extensions/GlobalPreferences/extension.json
    254 /srv/mediawiki/w/extensions/WikiEditor/extension.json
    254 /srv/mediawiki/w/extensions/CentralAuth/extension.json
    253 /srv/mediawiki/w/extensions/MobileFrontend/extension.json
    253 /srv/mediawiki/w/extensions/DataDump/extension.json
    253 /srv/mediawiki/w/extensions/ConfirmEdit/ReCaptchaNoCaptcha/extension.json
    251 /srv/mediawiki/w/extensions/BetaFeatures/extension.json
    248 /srv/mediawiki/w/extensions/OAuth/extension.json
    246 /srv/mediawiki/w/extensions/VisualEditor/extension.json
    244 /srv/mediawiki/w/extensions/Scribunto/extension.json
    244 /srv/mediawiki/w/extensions/GlobalCssJs/extension.json
    243 /srv/mediawiki/w/extensions/Interwiki/extension.json
    242 /srv/mediawiki/w/extensions/GlobalBlocking/extension.json
    242 /srv/mediawiki/w/extensions/EventStreamConfig/extension.json
    241 /srv/mediawiki/w/extensions/IncidentReporting/extension.json
    241 /srv/mediawiki/w/extensions/EventLogging/extension.json
    238 /srv/mediawiki/w/extensions/LocalisationUpdate/extension.json
    238 /srv/mediawiki/w/extensions/CookieWarning/extension.json
    236 /srv/mediawiki/w/extensions/ManageWiki/extension.json
    235 /srv/mediawiki/w/extensions/OATHAuth/extension.json
    235 /srv/mediawiki/w/extensions/Nuke/extension.json

Note: this fatrace is for files accessed by any process on the system, not just php-fpm. Therefore, you'll see that my 'fatrace.txt' is included in this list too.

Using vmtouch to cache every file into memory is not possible, since RAM is not infinite (for obvious reasons). However, caching the following popular files might give great results:

  • /srv/mediawiki/w/extensions/*/extension.json (1.7M)
  • /srv/mediawiki/w/skins/*/skin.json (164K)
  • /srv/mediawiki/w/cache/databases.json (224K)
  • /srv/mediawiki/w/cache/*wiki.json (6.2M)
  • /etc/ssl/certs/* (1.8M)
  • /usr/share/ca-certificates/mozilla/* (504K)
  • Most popular cdb files (42M)
    • /srv/mediawiki/w/cache/l10n/l10n_cache-en.cdb
    • /srv/mediawiki/w/cache/l10n/l10n_cache-zh-cn.cdb
    • /srv/mediawiki/w/cache/l10n/l10n_cache-it.cdb
    • /srv/mediawiki/w/cache/l10n/l10n_cache-zh-hant.cdb
    • /srv/mediawiki/w/cache/l10n/l10n_cache-ja.cdb
    • /srv/mediawiki/w/cache/l10n/l10n_cache-zh.cdb
    • /srv/mediawiki/w/cache/l10n/l10n_cache-es.cdb
    • /srv/mediawiki/w/cache/l10n/l10n_cache-nl.cdb
    • /srv/mediawiki/w/cache/l10n/l10n_cache-zh-tw.cdb
    • /srv/mediawiki/w/cache/l10n/l10n_cache-ko.cdb
    • /srv/mediawiki/w/cache/l10n/l10n_cache-de.cdb

@Paladox: see P381. Ideally, you turn the vmtouch (daemon) into a systemd service (a type of unit) that will run this script on every puppet run, after which you can restart the systemd service (to pick up new files).

If restarting the service is required to pick up changes, databases.json and *wiki.json can't be cached

In T6765#134610, @John wrote:

If restarting the service is required to pick up changes, databases.json and *wiki.json can't be cached

So far I was able to test, changes are picked up automatically :)