HF and Pages Loading Slow

Alright, so the database lock might have been a red herring. Did some other stuff, and it seems to have really helped:

Forum slowdown fix — Dec 2, afternoon


The symptom:
Even after this morning's PHP fixes, pages were still taking 5–10 seconds to start loading, intermittently for members and on almost every request for guests.


What I found:
  • The database wasn't it. MySQL was idle even during slow loads.
  • Timing from the server itself showed every request waiting 7–10 seconds before the first byte, even for a static file with no PHP involved, so the delay was in Apache.
  • Apache's status page showed all 150 of 150 connection slots busy and 0 idle. Nearly all were in the "reading request" state: clients holding connections open without sending anything. Every new request waited in line for a free slot.
  • Connections per IP showed no single abuser, but a constantly rotating set of visitors each holding 4–6 connections. That's typical of HTTP/1.1, which Apache's old prefork mode forced every browser and bot to use. (One persistent visitor was ClaudeBot, Anthropic's crawler, but at 14 of about 150 connections it wasn't the main cause, so we didn't block it.)
What I changed:
  1. Apache timeouts(WHM → Apache Configuration → Global Configuration):
    • Timeout: 300 → 30 seconds
    • KeepAliveTimeout: 5 → 3 seconds
    • The effect was immediate: 150 busy / 0 idle became about 80 busy / 56 idle.
  2. Switched Apache from prefork to mpm_eventin EasyApache 4, which also added:
    • mod_http2: browsers now use one connection instead of about six. Confirmed HTTP/2 in the browser.
    • mod_reqtimeout: wasn't installed before. It drops clients that send requests too slowly, instead of letting them hold slots.
    • mod_cgid replaces mod_cgi; no functional change.
  3. Raised Apache's limits for event mode: Server Limit 16, Max Request Workers 150 → 400.
Also earlier this afternoon: raised MySQL's InnoDB buffer pool from 128 MB → 2 GB, set live and saved in /etc/my.cnf.d/zz-halforums.cnf.

Result:
  • Time to first byte: 7–10 s → about 0.22 s, consistently.
  • Apache now: about 9 busy / 116 idle out of 400.
Found along the way: about 2.2 GB of the forum's tables are still MyISAM (including xf_post and xf_search_index), a holdover from older versions. MyISAM locks a whole table on every write, so I'm converting them to InnoDB tonight, with the board closed and a fresh backup taken first.

Still to do:
  • Browser caching rules in .htaccess, so static files aren't re-downloaded on every page.
  • XenForo's guest page cache, before reopening guest access fully.
  • Longer term: moving off CentOS 7, and PHP 8.2 → 8.3.
 
I fell asleep and didn't do the innodb conversion. I may hold off on that if the forum continues to behave acceptably.
 
To be 100% transparent I am a fucking meat proxy for Claude in this endeavor.

It is fucking SCARY how fucking smart Claude is/comes off as.

Yes yes yes! Claude is the only reason I have Ironwood on Foundry. Right now I'm using Claude to reverse engineer a mod that I really like but can't do any editing for.
 
1796336530853.png


I'm gonna say 725 pages of individual bot visits in 15 minutes with no slowdowns means what's been done so far is probably enough.
 
We got hit by a new scraper fleet this morning that spiked our CPU usage higher than I've ever seen it.

1796405406037.png


For clarity, that's of the preceding 20,000 HTTP requests to the site, 19,469 were marked as Chrome on desktop linux. That seems a *particularly odd* combination. Taking steps.
 
Forum CPU spike — Dec 4, ~11:00 AM

What happened:
The server's CPU suddenly spiked. All 32 PHP worker processes were maxed out, using about 2.7 of the server's 4 cores, and the PHP-FPM log showed the pool repeatedly hitting its worker limit (11:02, 13:28, and 17:20 server time, which is UTC).

Cause: A scraper fleet. Of the last 20,000 requests in the access log, 19,469 (97%) came from one identical browser identity:

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/158.0.0.0 Safari/537.36

Why we're confident it's bots and not people:
  • Real visitors show a varied mix of browsers, mostly phones, with a few dozen requests each.
  • Thousands of requests from the exact same desktop Linux identity doesn't happen naturally.
  • It claims Chrome 158, ahead of the Chrome versions our real visitors use (142–151). Scraper fleets often stamp a fake version on their headless browsers.

The top requested URL was /css.php (3,219 hits). That's XenForo generating stylesheets in PHP. Real browsers cache it, but headless scrapers request it fresh every time, on top of the pages themselves.

What I did:
  1. Blocked that exact identity in .htaccess(top of public_html/.htaccess; backup at .htaccess.bak):
    • Requests with that exact user agent get an instant 403 Forbidden from Apache, before PHP runs.
    • Members logged in with "Stay logged in" are exempt, in case a real member happens to match.
    • It worked immediately: within minutes, about 1,400–1,600 of that identity's recent requests were 403s, at roughly 9 per second at first.
  2. Turned on XenForo's caching(end of src/config.php, cache folder /home/halforu1/xf_cache):
    • CSS cache: css.php is served from cache instead of rebuilt each time.
    • Guest page cache (5 minutes): repeat guest and bot requests for the same page are served from cache.

Result: CPU is back to normal levels, and the 403s are dwindling, so the fleet is backing off or switching identity.

Not changed: I left PHP max_children at 32. CPU was the bottleneck, so more workers would just have split the same cores further.

If this becomes a recurring chore, it's worth putting the site behind Cloudflare, whose bot detection works on behavior rather than names.
 
Back
Top