Problem
A WordPress Multisite translation platform (GlotPress 4.0.3 + WP 6.8.3) running 67 subsites exhibits severely degraded performance: homepage TTFB is 5.7 seconds, while Traditional Chinese pages (/zh-tw/, /zh-hk/) suffer TTFB up to 45 seconds. Server load remains persistently above 30.
Server hardware is robust: 80 CPU cores, 62 GB RAM, PHP 8.3, and Redis (via Object Cache Pro) are already in place — yet all 22 PHP-FPM workers consistently run at >80% CPU utilization.
Root Cause Analysis
Three compounding issues were identified:
1. OpenCC Dictionary Sorting in wp-chinese-converter
This is the single largest performance bottleneck. The plugin uses the OpenCC PHP library for Simplified–Traditional Chinese conversion. The core inefficiency lies in the get_prepared_dictionaries() method in class-wpcc-opencc-converter.php:
// 53,650 dictionary entries — sorted on *every request*
uksort($flat, function ($a, $b) {
return mb_strlen($b) <=> mb_strlen($a);
});
Although $this->prepared[] provides intra-request caching, PHP-FPM spawns a new process per request — meaning dictionary sorting runs afresh every time. Sorting 53,650 entries using uksort with mb_strlen comparisons consumes several seconds per request.
Further, the subsequent strtr($output, $dict) replacement over 50,000+ entries is itself extremely slow.
2. Missing robots.txt — Aggressive Crawler Traffic
No robots.txt file exists, allowing crawlers like MJ12bot to crawl deep into translation archives — e.g., /zh-hk/tag/right-sidebar/page/1105 (yes, page 1105). GPTBot, OAI-SearchBot, Bytespider, SemrushBot, and ClaudeBot are also concurrently crawling.
Each crawler request triggers a full PHP execution pipeline: full WordPress bootstrap, OpenCC dictionary sorting, and large-scale strtr replacement — all CPU-intensive operations. Among the most recent 10,000 requests, ~10% originated from such crawlers — yet they disproportionately target translation-heavy pages.
3. Cavalcade Cron Tasks Stuck
Cavalcade (a WordPress cron replacement) has 63 zombie action_scheduler_run_queue tasks stuck since November 2025. Five Cavalcade workers each consume ~95% CPU. Compounding this, WP-Rocket’s activation triggered RUCSS generation and preload jobs across all 67 subsites simultaneously — overwhelming system resources.
4. wp-chinese-converter Sets Cookies, Bypassing Caching
The plugin sets Set-Cookie: wpcc_variant_xxx on every request. This causes nginx fastcgi_cache to skip caching those responses by default — even if cache rules are correctly configured.
Optimization Plan
Step 1: Block Crawlers (Immediate Impact)
Create robots.txt to disallow low-value crawlers:
User-agent: MJ12bot
Disallow: /
User-agent: Bytespider
Disallow: /
# Repeat for GPTBot, OAI-SearchBot, SemrushBot, DotBot, AhrefsBot, PetalBot, ClaudeBot
User-agent: *
Disallow: /wp-admin/
Disallow: /glotpress/
Disallow: /translate/
Disallow: /zh-tw/tag/
Disallow: /zh-hk/tag/
Also block them directly at the nginx layer (robots.txt is only advisory):
# /www/server/panel/vhost/nginx/extension/wpfanyi.com/bot_block.conf
if ($http_user_agent ~* "(MJ12bot|Bytespider|GPTBot|OAI-SearchBot|SemrushBot|DotBot|AhrefsBot|PetalBot|ClaudeBot)") {
return 403;
}
Step 2: Enable nginx fastcgi_cache (Fundamental Fix)
Define the cache zone in the nginx http block:
# 0.wpfanyi_fcgi_cache.conf (in http block)
fastcgi_cache_path /path/to/nginx-cache levels=1:2
keys_zone=wpfanyi_cache:100m max_size=2g inactive=60m use_temp_path=off;
Enable caching in the server block — critically, ignore wp-chinese-converter’s Set-Cookie:
set $skip_cache 0;
if ($request_method = POST) { set $skip_cache 1; }
if ($arg_s) { set $skip_cache 1; }
if ($http_cookie ~* "wordpress_logged_in_") { set $skip_cache 1; }
if ($request_uri ~* "/wp-admin/|/wp-login.php|/wp-json/") { set $skip_cache 1; }
fastcgi_cache wpfanyi_cache;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_valid 200 301 60m;
fastcgi_cache_valid 404 1m;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache_use_stale error timeout updating http_500 http_503;
fastcgi_cache_lock on;
# Critical: Ignore Set-Cookie headers from wp-chinese-converter
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_hide_header Set-Cookie;
add_header X-FastCGI-Cache $upstream_cache_status;
Step 3: OPcache-Based File Caching for OpenCC Dictionaries
Modify get_prepared_dictionaries() to serialize and cache the sorted dictionary as a PHP file, then load it via include — leveraging OPcache for near-instant bytecode execution:
private function get_prepared_dictionaries(string $strategy): array {
if (isset($this->prepared[$strategy])) {
return $this->prepared[$strategy];
}
// Try loading from cached PHP file (OPcache-accelerated)
$cache_file = WP_CONTENT_DIR . "/cache/wpcc-dictionaries/dict_" . md5($strategy) . ".php";
if (file_exists($cache_file)) {
$prepared = include $cache_file;
if (is_array($prepared) && !empty($prepared)) {
$this->prepared[$strategy] = $prepared;
return $prepared;
}
}
// First-time: sort and write to cache file
$sets = Dictionary::get($strategy);
// ... unchanged uksort logic ...
// Write sorted dict as executable PHP file — OPcache will auto-cache bytecode
$export = "<?php\nreturn " . var_export($prepared, true) . ";\n";
$tmp = $cache_file . ".tmp." . getmypid();
if (@file_put_contents($tmp, $export, LOCK_EX) !== false) {
@rename($tmp, $cache_file);
if (function_exists("opcache_compile_file")) {
@opcache_compile_file($cache_file);
}
}
return $prepared;
}
Step 4: Limit Cavalcade CPU Consumption
# /etc/systemd/system/cavalcade.service
[Service]
Nice=19
CPUQuota=200%
CPUWeight=50
```## Optimization Results
| Metric | Before Optimization | After Optimization |
|--------|---------------------|--------------------|
| Server Load | 34.87 | 3.14 |
| Homepage TTFB | 5.7 s | 60 ms |
| zh-tw Page TTFB | 45 s | 66 ms |
| zh-hk Page TTFB | 6 s | 65 ms |
| PHP-FPM Workers | 22 workers at 80%+ CPU | 10 workers at 19% CPU |
## Lessons Learned
1. **`wp-chinese-converter` / OpenCC is a CPU killer** — Sorting 50,000 dictionary entries with `uksort`, comparing strings using `mb_strlen`, and performing large-scale `strtr` replacements on every Traditional Chinese page triggers heavy CPU usage. Persistent caching is mandatory.
2. **`Set-Cookie` silently breaks HTTP caching** — Plugins that set cookies on every request cause nginx `fastcgi_cache` to skip caching by default (since responses containing `Set-Cookie` headers are excluded). You must explicitly configure `fastcgi_ignore_headers Set-Cookie`.
3. **A translation site without `robots.txt` is a crawler magnet** — Translation-site URL structures (e.g., `/zh-tw/tag/xxx/page/N`) generate massive numbers of crawlable pages; crawlers will endlessly paginate.
4. **Cavalcade + Action Scheduler can spiral out of control** — Accumulated zombie tasks combined with WP-Rocket generating background tasks across 67 subsites simultaneously leads to CPU overload. Worker count and CPU quotas must be strictly limited.
5. **nginx `fastcgi_cache` is the most effective front-end optimization for multi-site WordPress** — A single layer of caching resolves performance issues for 99% of visitors: simple to configure and delivers immediate, dramatic improvements.
6. **Object Cache Pro’s metrics snapshots can balloon in size** — The `objectcache_snapshots` entry in `wp_sitemeta` can grow to hundreds of KB; individual writes may take several seconds. Regular cleanup is required.