Although, everything was running fine on my Raspberry Pi 3, there was one thing that bothered me and took me quite a while to find a solution for it. Every now and then, Lighttpd started to hang for many seconds. After just waiting, or impatiently restarting Lighttpd, everything worked fine again for some time. Unnecessary to say that this situation was not very pleasing and a solution had to be found.
After looking around the internet, I got the strong feeling that the FastCGI configuration is causing the problem. In particular, PHP_FCGI_MAX_REQUESTS seems to be the one to blame.
I have PHP7 on my Raspberry Pi 3 and the parameters we are looking for are accessible with the following commands (including a backup of the original configuration). This can vary, depending on which version of PHP you are using.
cd /etc/lighttpd/conf-available/ sudo cp 15-fastcgi-php.conf 15-fastcgi-php.conf.bak sudo nano 15-fastcgi-php.conf
Within the configuration, the following part is of special interest for us. This was what my default installation looked like.
... "max-procs" => 1, "bin-environment" => ( "PHP_FCGI_CHILDREN" => "4", "PHP_FCGI_MAX_REQUESTS" => "10000" ...
I changed the values for max-procs and PHP_FCGI_MAX_REQUESTS like shown below. For more detailed information about the function of the parameters, you should read the article Optimizing FastCGI performance.
... "max-procs" => 3, "bin-environment" => ( "PHP_FCGI_CHILDREN" => "4", "PHP_FCGI_MAX_REQUESTS" => "500" ...
After changing the values, you have to restart Lighttpd, so that the changes will take effect.
sudo /etc/init.d/lighttpd restart
Right after restarting the web server, you can see the RAM consumption of the system increasing, due to the increase of max-procs. I am not 100% sure, if the values that I have chosen are the best ones for the Raspberry Pi 3, but up to now, Lighttpd is running just fine, without any hangs, delays or hiccups and the RAM consumption also seems to be fine.