8-core 24GB VPS tsis muaj lub cim xeeb lawm? Kev kho cov txheej txheem PHP-FPM nyuaj heev hauv HestiaCP

Tus naj npawb ntawm cov neeg siv tib lub sijhawm uas lub server tuaj yeem tswj hwm tsis yog nyob ntawm seb nws muaj pes tsawg lub cores, tab sis nyob ntawm seb txhua tus txheej txheem siv pes tsawg lub cim xeeb.

Cov lus no yuav zoo li yog kev ua kom chim siab, tab sis nws yog qhov kev paub tiag tiag thiab mob siab tshaj plaws hauv kev lag luam kev ua haujlwm thiab kev saib xyuas.

Vim li cas kev nco qab thiaj yog qhov tseem ceeb ntawm kev cuam tshuam?

Muaj ntau tus neeg pom VPS nrog 8-core CPU thiab 24GB ntawm lub cim xeeb thiab xav tias lawv tuaj yeem khiav tau ntau pua PHP-FPM cov txheej txheem yooj yim.

Txawm li cas los xij, qhov tseeb, kev siv RSS nco ntawm ib qho txheej txheem PHP feem ntau siab txog 200MB.

Nov yog qhov tshwm sim tau los ntawm kev sim tiag tiag ntawm kab hais kom ua:

ps --no-headers -o rss -p $(pgrep php-fpm) | awk '{sum+=$1} END {print sum/NR/1024 " MB"}'

Hauv HestiaCP lub moj khaum nyuaj thiab ntau lub plugin ib puag ncig, tshwj xeeb tshaj yog tsis muaj OPcache optimization, 200MB yog tus qauv.

Qhov no txhais tau tias lub cim xeeb, tsis yog CPU, yog qhov txwv tsis pub tshaj plaws uas txiav txim siab qhov siab tshaj plaws ua ke.

8-core 24GB VPS tsis muaj lub cim xeeb lawm? Kev kho cov txheej txheem PHP-FPM nyuaj heev hauv HestiaCP

Cov ntaub ntawv teeb tsa pom zoo (php-fpm.conf)

pm = dynamic
pm.max_children = 80
pm.start_servers = 16
pm.min_spare_servers = 8
pm.max_spare_servers = 24
pm.max_requests = 500
pm.process_idle_timeout = 10s
request_terminate_timeout = 60s

Kev suav lej parameter thiab kev teeb tsa

Configuration parametersTeeb tsa tus nqiKev suav lej thiab kev teeb tsa ntawm lub hauv paus
pmdynamicHom dynamic tso cai rau kev ntxiv lossis rho tawm cov txheej txheem raws li qhov xav tau ua ke, sib npaug ntawm qhov ceev teb thiab kev siv lub cim xeeb.
pm.max_cov me nyuam80Tag nrho 24GB lub cim xeeb tsis suav nrog lub kaw lus kernel thiab MySQL/RedisTom qab Nginx, kwv yees li 16GB tseem tshuav rau PHP.16,384 MB / 200 MB ≈ 81.9Teem nws rau 80 tuaj yeem tshem tawm tag nrho OOM (Tawm ntawm Nco) thaum lub sijhawm ua haujlwm siab.
pm.start_servers16Kev ua kom sov ua ntej thaum pib siv yog teem rau ob npaug ntawm tus lej ntawm CPU cores (8 cores × 2 = 16) kom ntseeg tau tias qhov kev pabcuam tuaj yeem ua haujlwm tib lub sijhawm tom qab rov pib dua.
pm.min_spare_servers8Teem lub CPU core suav rau 8 cores kom ntseeg tau tias cov lus thov tshiab tuaj yeem teb tau txhua lub sijhawm thaum lub sijhawm tsheb khiav tsawg.
pm.max_spare_servers24Teem nws rau 3 npaug ntawm tus lej ntawm CPU cores (8 cores × 3 = 24) kom khaws cov txheej txheem nruab nrab tom qab cov tsheb khiav rov qab, txhawm rau tswj hwm qhov kev hloov pauv me me.
pm.max_requests500Yog tias ib qho txheej txheem ncav cuag lub hauv paus loj ntawm 200MB, kev txo tus naj npawb ntawm cov kev thov rau 500 yuav rhuav tshem thiab rov tsim dua cov txheej txheem, uas tuaj yeem ntxuav cov cim xeeb tsis pom tseeb sai dua.
pm.process_idle_timeout10sTshaj dhau min_spare_servers Cov txheej txheem tsis ua haujlwm raug tso tawm thiab xa rov qab mus rau lub cim xeeb ntawm lub system tom qab 10 vib nas this tsis muaj kev thov.

Cov Chaw Txhawb Nqa Tseem Ceeb thiab Cov Lus Qhia Txog Kev Txhim Kho

1. Lub sijhawm tiv thaiv kev qaug zog

request_terminate_timeout = 60s Qhov ntawd yog qhov tseem ceeb.

Nws tuaj yeem yuam kom cov txheej txheem uas raug daig vim yog qhov teeb meem database lossis kev thaiv API thib peb.

Lub sijhawm ntawd, Nginx's fastcgi_read_timeout Yuav tsum khaws cia tsawg kawg yog 60 vib nas this, txwv tsis pub tus neeg siv khoom yuav tau txais nws ua ntej lub sijhawm. 504 Gateway Timeout.

2. Cov tswv yim los kov yeej qhov teeb meem ntawm kev nco qab

Qhov siab tshaj plaws ntawm 80 cov txheej txheem ua ke txhais tau tias nyob rau hauv cov xwm txheej ua ke hnyav, lub kaw lus tuaj yeem tswj hwm qhov siab tshaj plaws ntawm 80 qhov kev thov HTTP dynamic tib lub sijhawm.

Yog tias koj xav txhim kho lub peev xwm ntxiv, qhov kev tsom mus rau yuav tsum yog txo kev siv lub cim xeeb rau ib qho txheej txheem.

  • Qhib OPcache: nyob rau hauv php.ini Kev teeb tsa nruab nrab opcache.enable=1 thiab opcache.memory_consumption=256Bytecode caching tuaj yeem txo qhov kev siv nco ntawm ib qho txheej txheem los ntawm 200MB mus rau 60 ~ 100MB.
  • Kev tswj hwm tsim nyog ntawm memory_limit: yuav php.ini nruab nrab memory_limit Txwv rau 128M los yog 256MTxhawm rau tiv thaiv cov ntawv sau tsis zoo ntawm tus kheejtxwvNws siv ntau lub cim xeeb.

Thaum lub cim xeeb siv ntawm ib qho txheej txheem poob rau 100MB ...pm.max_children Nws tuaj yeem hloov kho kom ruaj ntseg mus rau 150 Tsis tas li ntawd xwb, lub peev xwm ua ke tau yuav luag ob npaug.

Cov kev xav tseem ceeb uas tau hais tawm

Raws li cov lus qhia hauv cov ntaub ntawv Nginx official :

"Cov ntawv thov FastCGI yuav tsum tau saib xyuas nrog cov lus qhia txog lub sijhawm kom tiv thaiv kev siv cov peev txheej tsis txaus."
(Tau los ntawm: Nginx Cov Ntaub Ntawv)

Phau ntawv qhia PHP raug cai hais meej meej tias:

"pm.max_children txhais tus naj npawb siab tshaj plaws ntawm cov txheej txheem me me uas yuav tsum tau tsim. Qhov no yog qhov kev qhia tseem ceeb tshaj plaws."
(Tau los ntawm: Cov ntaub ntawv PHP-FPM)

Cov kev xav uas muaj hwj chim no zoo sib xws nrog peb cov kev coj ua, ua pov thawj tias kev xav txog kev ua kom zoo tshaj plaws tsis yog raws li kev paub dhau los xwb, tab sis kuj yog raws li cov qauv zoo tshaj plaws.

Xaus Lus: Kuv Cov Kev Xav thiab Cov Lus Tseem Ceeb

Hauv cov xwm txheej sib xws siab, CPU yog lub cav, lub cim xeeb yog lub tank roj, thiab PHP-FPM yog tus xa xov xwm.

Txawm lub cav muaj zog npaum li cas los xij, yog tias lub tank roj tsis loj txaus, lub tsheb yuav mus tsis deb heev.

Cov kws tshaj lij tiag tiag tsis dig muag ua kom tiav qhov ntsuas siab tshaj plaws, tab sis xam qhov tseeb ntawm kev siv lub cim xeeb ntawm txhua txoj haujlwm kom tsis txhob muaj kev pov tseg thiab kev puv dhau.

Lub ntsiab lus ntawm kev ua kom zoo tshaj plaws yog nrhiav qhov sib npaug zoo tshaj plaws nrog cov peev txheej tsawg.

Qhov no tsis yog tsuas yog ib qho thev naus laus zis xwb, tab sis kuj yog ib qho kev xav.

Yog li ntawd, tsum tsis txhob ntseeg tias "tus naj npawb ntawm cov cores txiav txim siab txhua yam." Qhov tseeb txiav txim siab qhov txwv ntawm kev sib koom ua ke yog koj txoj kev tswj hwm lub cim xeeb.

Ua ib yam dab tsi thiab ua kom koj lub VPS zoo tshaj plaws, siv txhua qhov nco kom zoo tshaj plaws.

评论 评论

您的邮箱地址不会被公开。必填项已用*标注

Scroll rau saum