Problems activating your account? Send notification email to: admin@post4vps.com
Host4Fun Budget VPS Hosting
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to fix php-fpm overloading
#1
long time not making any tutorial . but i think now is the time

short background . recently my web backend for my android application exploded in popularity and because of that my vps cannot handle it . it starting to give error 500 , 520 , 502 , etc . after some finding i found out the cause to be the php-fpm that limit the processing power and make my site giving that error . i use php for backend simply because i dont know python,nodejs,etc

to fix it edit the http://www.conf file in /etc/php/{php version}/{apache or fpm(nginx)}/pool.d/www.conf . for example i use php7.0 and nginx so i use
nano /etc/php/7.0/fpm/pool.d/www.conf

now edit some variable on that http://www.conf file and find this variable and then change it like this
pm = dynamic
pm.max_children = 100
pm.start_servers = 100
pm.min_spare_servers = 25
pm.max_spare_servers = 100

and then find the pm.max_request and remove the ';'
pm.max_request = 500

now restart the php-fpm using
service php7.0-fpm restart (depend on what php version you are using)

and after that i get the error much less but still slowdown mostly because of the traffic . it not totally fix it for me but enough to be usable . hope you find this tutorial useful
Terminal
humanpuff69@FPAX:~$ Thanks To Shadow Hosting And Post4VPS for VPS 5
Reply
#2
Good tutorial. It is always a challenge when websites suddenly explodes in popularity and gains much traffics.

If re-configuring php does not work well, perhaps you may want to consider adding redis caching or something similar at the backend.
Special thanks to VPSVortex for a great KVM VPS.

Reply
#3
also an update . the site is just little bit faster with that trick . the main problem turned out to be one of the HEAVY mysql queries , also my server is 100% all the time at that time . one of the query use LIKE '% %' function that search for specific string each rows and the problem is that by that time i already have 100k rows of data and that take a long time so the mysql server is overloaded due to that . i removed the script that use that query and the site just magically go to normal but with some slowdown mostly because of there still other query and the fact that my application went viral and still kind of to this day
Terminal
humanpuff69@FPAX:~$ Thanks To Shadow Hosting And Post4VPS for VPS 5
Reply
#4
Great tutorial! PHP-FPM optimization is an important subject if you use PHP-FPM with Nginx or another web server to run PHP scripts and software. So often issues experienced with sites are related to PHP and SQL scripts taking long time or hitting limitations. Using this guide can at least fix a part of the issues Smile .

The SQL query issue is a different thing though. The best would be to optimize the query in order to push down the query execution time as much as possible. This will increase performance. Sometimes if you use a custom database a redesign might help.

Good job!
With best regards
Hidden Refuge
IT specialist for system integration

Reply
#5
Good tutorial and welcome back to the tutorial section :d
Btw seems that this increases the site preformance.
Gimme +rep Heart
[Image: img.php?userid=496]
Thanks For Post4VPS and Virmach for the amazing VPS 9
Reply
#6
(06-11-2019, 06:58 PM)youssefbasha Wrote:  Good tutorial and welcome back to the tutorial section :d
Btw seems that this increases the site preformance.

it will increase most probably , basically it allocate more resource to the php-fpm process . a process that is used for processing all the php code that loaded using nginx or apache2
by default php allocate low resource . i think they assume it only used for low traffic website . because it hit very hard when my web app backend get massive traffic
Terminal
humanpuff69@FPAX:~$ Thanks To Shadow Hosting And Post4VPS for VPS 5
Reply
#7
humanpuff69. I would like to know your server specs and what else you run on it. Also if you don't mind, I would like a simple stat on the rate of requests when the errors starts showing up a lot.

It would give a better idea on when to use such numbers as you have given above.

Thankd for the tute.
Thanks to cubedata.net and post4vps.com for my awesome vps8.
Reply
 


Forum Jump:


Users browsing this thread: 1 Guest(s)

Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - SSDBlaze - VPSlices - Abc-Hosters - Hyper Expert - Shadow Hosting - Bladenode - HostDoc - Hostlease


About Post4VPS

Post4VPS is a forum/destiny where you can Delploy Your Free VPSs just by the Power of Posts.

We Provide VPSs of many locations like Germany,US,Canada,France,London,etc.

We also Provide VPSs of Both Linux and Windows OS.