arrow_upward

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 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 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
#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.


#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
#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!
[Image: zHHqO5Q.png]
#5
Good tutorial and welcome back to the tutorial section :d
Btw seems that this increases the site preformance.
#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
#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.
Sincere Thanks to VirMach for my VPS9. Also many thanks to Shadow Hosting and cubedata for the experiences I had with their VPSs.


person_pin_circle Users browsing this thread: 1 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting