ol-www0 performance limits w/ modsec
We need 2 extra cores to run modsec (i.e. w/ 8 cores, only 6 workers for nginx to prevent starvation).
@cdrini + @abezella have added 2 cores (bringing us to 8 nginx workers)
Next steps include having nginx -> fail2ban very clearly bad agents + exempting very clearly OK requests (e.g. specific /search.json) to reduce the modsec load on ol-www0
[!WARNING] This issue requires access to internal infrastructure, production systems, or institutional knowledge unavailable to community contributors. It can only be resolved by a maintainer or staff member.
⚠️ Contributors, this issue will be ready to work on once:
- [ ] Triage — maintainers will add
Priority: *andLead: @*to replaceNeeds: TriageandNeeds: Lead - [ ] Needs: Investigation — root cause (modsecurity CPU overhead vs. nginx/haproxy connection handling vs. something else) is unknown; the issue body has no problem statement to investigate from
- [ ] Needs: Breakdown — issue lacks concrete implementation steps; not yet actionable
- [ ] Needs: Staff / Internal — diagnosis needs production CPU/latency metrics and likely coordination on the WAF ruleset, which lives outside this repo
Context
docker/web_nginx.conf:80-81enablesmodsecurity on;against/olsystem/etc/nginx/modsecurity_openlibrary.conf— the actual WAF ruleset lives in the privateolsystemrepo, not here. Added via #12592, rebuilt via #12769 ("Build modsecurity to avoid it being outdated", merged 2026-05-20).docker/nginx.conf:8-9—worker_processes 6;with the comment "6 cores on ol-www0, 8 on ol-covers0";worker_connectionswas already doubled to 4096 in #12359 as a prior response to www0 load pressure.- #12994 (open, unmerged) — "Enable keepalive from nginx to haproxy to reduce www0 CPU" — adds a keepalive upstream block for the nginx→haproxy hop, targeting www0 CPU directly. Not clear from either issue whether it addresses the bottleneck this issue is about.
- #12591 ("Modsecurity", closed) is the original WAF proposal for this host and was also labeled
Needs: Staff / Internalfor the same production-access reason — worth checking its comment thread for prior context onSecRuleRemoveByTagtuning already discussed there.
Issue Assessment
Open questions
- What is the actual symptom — elevated latency, CPU saturation, dropped/5xx requests, or something else? The issue body's Problem, Reproducing, and Context sections are all unfilled template placeholders.
- Is this a regression introduced by the modsecurity rollout (#12592/#12769), or a capacity issue independent of it?
- Does #12994 already address this, partially address it, or target an unrelated bottleneck?
- Is
ol-covers0in scope, or is this strictlyol-www0?
Action items
- [ ] Fill in the Problem section with the specific symptom and evidence (metrics, logs, timeframe)
- [ ] State measurable impact (request latency, error rate, or CPU numbers) and how success will be verified
- [ ] Confirm whether #12994 is a candidate fix or unrelated, and link it explicitly if so
- [ ] Assign a lead — this is squarely ops/infra; cc @scottbarnes for
Needs: Lead
Full triage checklist (maintainers / Richy)
- [x] Triage — correct labels applied or removed
- [ ] Problem / opportunity — problem is clear, audience identified, actionable
- [ ] Scope — issue is well-scoped; does not try to do too many things
- [ ] Justification — reasoning and impact stated; sufficient for leads to prioritize
- [ ] Success & testing criteria — defines what "done" looks like, verifiable by a contributor
- [ ] Proposal & breakdown — concrete plan present; checklist actionable for a contributor
- [ ] If bug: environment & repro steps — browser, version, local vs prod; steps to reproduce
- [x] Risks, concerns, open questions — identified and surfaced (any security or privacy implications?)
- [x] Richy context — relevant code, commits, PRs reviewed; no duplicate issue found (reviewed #12591, #12592, #12769, #12359, #12994,
docker/nginx.conf,docker/web_nginx.conf) - [ ] References — screenshots, designs, docs, and links present where needed
[!NOTE] This comment was automatically generated by Richy, via PAM, Open Library's Project AI Manager, on behalf of @mekarpeles. Richy is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting.
Possibly related symptom: I've been unable to upload book cover images (via the "Add Cover" / Book Covers dialog) for about a week now.
Desktop (browser): upload fails with The server at openlibrary.org sent back an error: 460 No Reason Phrase Mobile: same upload fails silently; no error shown, cover just never appears
Tried from two different networks (ruling out a local VPN/firewall issue on my end), same result both times. Given this issue mentions nginx worker starvation under modsec load, wondering if larger POST requests like image uploads are getting dropped or timing out. Happy to provide more details if useful.
@trevorpower related to #12718 but not this issues -- there are some other 460 reports there and we are moving towards daily triage of these events by reviewing anonymized logs, please do repost there! Thank you!
@trevorpower I dug into this one and you're correct that it's ModSecurity, but it's not the worker-starvation described in this issue.
The specific trigger is file size: cover uploads over ~1 MB get rejected by the WAF with that 460 No Reason Phrase before they ever reach the app, while anything under ~1 MB goes through fine. I reproduced it on prod with a 976 KB image and a 1.1 MB version of the same image failed with the 460.
There's an open issue for the file uploads at #13232.
https://github.com/internetarchive/olsystem/pull/398
There are remaining follow-ups here, however, this is what the team has done:
- Specified a few high volume endpoints to exempt from modsec to save on CPU <--
- Exploring moving ol-web1 off OL cluster into kubernetes land (to reclaim ~8 over-subscribed cores)?
- in the queue behind solr-staging and possibly solr (?)
- Analyzing daily modsec logs to unblock more false positives and to catch bad actors
- promoting these bad actor cases to fail2ban rules that prevent 429 floods
As needed, we'll explore using verify_human endpoints to further secure the website.
A question for Ruben is if GET requests to book pages could be exempt...