FastCGI running concurrent processes without terminating them, so the performance will be optimized.
But it has some config to avoid memory leak.
If for some requests your program works fine and not facing 500 error all the times, i suggest you check the pm configuration of fastcgi:
- open /etc/php/7.0/fpm/pool.d/www.conf
- check to see if the pm is set to be dynamic. (fastcgi will handle number of processes dynamycally)
- check pm.max_children to be high enough. (if the max reached and requests not finished, you will face server error, because there is no other worker to handle request)
- if you changed the value, run sudo systemctl restart php-fpm to restart fastcgi.
Note
- check memory_limit of php.ini to see how much each php process will take and then by considering your RAM free space, choose the pm.max_children.