debugging
Technical notes on web development, DevOps, and AI integration.
2 articles
- 10:38devops
Blamed on DDoS, the Nginx Logs Disagreed
An hourly wave of 504s looked like an attack. The logs pointed at a dormant rate limit and a PHP-FPM pool out of workers.
TL;DR: Hourly 504 waves looked like a DDoS but were actually PHP-FPM worker exhaustion, worsened by request_terminate_timeout killing slow requests. Nginx rate limiting never fired because Cloudflare hid real client IPs, collapsing everyone into one $binary_remote_addr bucket. Fixes: enable Cloudflare caching, tune PHP-FPM pool settings, and rotate container logs with copytruncate.
#nginx#docker#cloudflare - 22:52tooling
Green Selftest, Then an ImportError Caused by a File Name
A CLI tool named keyword.py passed its own selftest yet broke import collections. sys.path order and a transitive import turned out to be the trap.
TL;DR: Naming a local file keyword.py shadows Python's stdlib keyword module because the script directory sits first in sys.path. The trap stays hidden until collections transitively imports keyword and crashes with a confusing ImportError. Fix: avoid stdlib names, run a quick import check, and use Python 3.11's -P flag as backup.
#python#tooling#debugging