Work out pm.max_children and spare servers from your RAM, what MySQL, Redis and the OS need, and your measured worker size. Get a copy-ready www.conf block.
PHP & VPS
PHP-FPM pm.max_children 계산기
서버 RAM, MySQL·Redis·OS 예약 메모리, 실측 워커 크기로 pm.max_children과 spare 서버 값을 계산하고 www.conf 설정을 바로 복사하세요.
Server memory
Reserved for other services (MB)
Headroom for traffic spikes and memory growth. 10–20% is typical; max 90% (higher values are reset to 90).
Measure it on your server (average RSS of all php-fpm processes):
Uses the same reservations, buffer and worker size as above.
How to Use
STEP 1
Enter total RAM and reservations
Put in your server RAM, then what the OS, MySQL/MariaDB (roughly innodb_buffer_pool_size plus overhead), Redis and anything else need. Check real usage with free -m and htop.
STEP 2
Measure your worker size
Copy the ps one-liner and run it on the server during normal traffic. Worker size varies widely by app, plugins and PHP settings, so measure yours instead of guessing.
STEP 3
Pick a pm mode and copy the config
Choose static, dynamic or ondemand, copy the block into your pool file (for example /etc/php/8.3/fpm/pool.d/www.conf) and reload PHP-FPM.
STEP 4
Verify under load
Watch free -m and the PHP-FPM log. If you see "server reached pm.max_children", use the reverse calculator to see how much RAM a higher limit needs.
사용 방법
STEP 1
총 RAM과 예약 메모리 입력
서버 RAM을 넣고 OS, MySQL/MariaDB(대략 innodb_buffer_pool_size + 오버헤드), Redis 등 다른 서비스가 쓰는 메모리를 입력하세요. 실제 사용량은 free -m, htop으로 확인합니다.
STEP 2
워커 크기 실측
ps 한 줄 명령을 복사해 평소 트래픽이 있을 때 서버에서 실행하세요. 워커 크기는 앱·플러그인·PHP 설정에 따라 크게 달라지므로 추측하지 말고 직접 측정하세요.
STEP 3
pm 모드 선택 후 설정 복사
static, dynamic, ondemand 중 하나를 고르고 생성된 블록을 풀 설정 파일(예: /etc/php/8.3/fpm/pool.d/www.conf)에 붙여넣은 뒤 PHP-FPM을 reload 하세요.
STEP 4
부하 상태에서 검증
free -m과 PHP-FPM 로그를 지켜보세요. "server reached pm.max_children" 경고가 보이면 역계산기로 더 높은 값에 필요한 RAM을 확인하세요.
Frequently Asked Questions
Subtract the RAM that everything else needs (OS, MySQL or MariaDB, Redis, Nginx) from total RAM, keep a 10–20% safety buffer, then divide by the average memory of one PHP-FPM worker and round down. Example for 4 GB with MySQL 1 GB and OS 512 MB: floor((4096 − 1536) × 0.9 ÷ 60) = 38 children.
It depends on worker size, not RAM alone. A 2 GB VPS with MySQL (512 MB), OS (384 MB) and 60 MB workers gives floor((2048 − 896) × 0.9 ÷ 60) = 17. A 4 GB VPS with MySQL 1 GB and OS 512 MB gives 38. Worker size varies widely by app and plugins, so measure yours with the ps command above; larger workers lower both numbers.
Run the ps and awk one-liner shown next to the worker-size field while the site is under normal traffic. It averages the resident memory (RSS) of all php-fpm processes. On Debian and Ubuntu the process is versioned, so replace php-fpm with php-fpm8.3 (or your version). Measure after workers have served requests for a while, because a fresh worker is smaller than a warm one.
static keeps all max_children workers alive: lowest latency, highest steady memory use, best for a dedicated busy server. dynamic keeps between min and max spare idle workers and is the safe default for most VPS. ondemand starts workers only when requests arrive and kills them after pm.process_idle_timeout (10s by default), which suits low-traffic sites or servers with many pools.
Too high: under a traffic spike every worker grows to full size, RAM runs out, the server swaps and the Linux OOM killer may kill MySQL. Too low: the PHP-FPM log shows "server reached pm.max_children setting" and requests queue up, which appears as slow pages or 502/504 errors. Start from the calculated value and adjust while watching memory and that log line.
자주 묻는 질문
총 RAM에서 다른 서비스(OS, MySQL·MariaDB, Redis, Nginx)가 쓰는 메모리를 빼고, 10–20% 안전 버퍼를 남긴 뒤 PHP-FPM 워커 1개의 평균 메모리로 나누고 내림합니다. 예: 4GB, MySQL 1GB, OS 512MB → floor((4096 − 1536) × 0.9 ÷ 60) = 38개.
RAM만이 아니라 워커 크기에 따라 달라집니다. 2GB VPS에 MySQL 512MB, OS 384MB, 워커 60MB면 floor((2048 − 896) × 0.9 ÷ 60) = 17입니다. 4GB VPS에 MySQL 1GB, OS 512MB면 38입니다. 워커 크기는 앱과 플러그인에 따라 크게 달라지므로 위의 ps 명령으로 직접 측정하세요. 워커가 클수록 두 값 모두 낮아집니다.
워커 크기 입력란 옆의 ps + awk 한 줄 명령을 평소 트래픽이 있을 때 실행하세요. 모든 php-fpm 프로세스의 상주 메모리(RSS) 평균을 MB로 보여줍니다. Debian·Ubuntu는 프로세스 이름에 버전이 붙으므로 php-fpm 대신 php-fpm8.3(사용 버전)으로 바꾸세요. 새로 뜬 워커는 작게 나오므로 요청을 어느 정도 처리한 뒤 측정합니다.
static은 max_children 개 워커를 항상 띄워 두어 지연이 가장 적지만 메모리를 계속 차지하므로 트래픽이 많은 전용 서버에 맞습니다. dynamic은 min~max spare 사이의 유휴 워커를 유지하며 대부분의 VPS에 무난한 기본값입니다. ondemand는 요청이 올 때만 워커를 만들고 pm.process_idle_timeout(기본 10초) 뒤 종료하므로 트래픽이 적거나 풀이 많은 서버에 적합합니다.
너무 크면: 트래픽이 몰릴 때 모든 워커가 최대 크기로 커져 RAM이 부족해지고, 스왑이 발생하며 리눅스 OOM killer가 MySQL을 종료시킬 수 있습니다. 너무 작으면: PHP-FPM 로그에 "server reached pm.max_children setting"이 찍히고 요청이 대기열에 쌓여 페이지가 느려지거나 502/504 오류가 납니다. 계산값에서 시작해 메모리와 로그를 보며 조정하세요.