PHP, MySQL and load

Production notes on Bitrix under load: PHP-FPM, OPcache, file sessions, slow query log, binlog, nginx fastcgi_cache, CDN versus composite cache, cron locks and PHP upgrades. With settings and numbers.

12 articles

Atomic file locking in PHP: the mkdir trick that needs no Redis

PHP developers have three common approaches to preventing parallel cron execution: advisory locks in the database, Redis SETNX with TTL, or ignoring the problem and getting duplicate runs. There's a fourth option: atomic mkdir, a POSIX primitive available on any filesystem with no external dependencies.

When CDN and Bitrix Composite fight each other

We added Cloudflare to a Bitrix store on Thursday evening. By Friday morning: "my cart is empty, I already added items." By Saturday: "the account page is showing someone else's data."

Four PHP behaviors we only caught in Bitrix production

PHP has four language-level behaviors that cause production performance problems in Bitrix: session file locking, OPcache stale entries on deploy, array copy-on-write memory doubling, and non-deterministic destructor order. These aren't bugs — they're documented behavior — but they only become visible under production load.

PHP 8.4 and Bitrix in Production: What Actually Breaks

The Bitrix release notes say "PHP 8.4 supported." Our first client to upgrade staging got 47 deprecated notices on a single homepage request and a broken payment module. None of it was in Bitrix core.

PHP-FPM pm.max_children: The Setting That Brings Bitrix Down Under Load

pm.max_children is the PHP-FPM configuration parameter that sets the maximum number of worker processes in a pool. On a busy Bitrix installation, getting this wrong is the most reliable way to turn a promotional spike into a 504 error wave — and the most reliable way to miss it during normal traffic.