PHP Gets Stuck

Sakamoto Ryōma

Verified User
Joined
Jun 4, 2011
Messages
69
I have a server with 4C/8T and 32GB Memory with the latest DirectAdmin and Debian 12. Recent clean install.

I have set the memory limit in php.ini to firstly 512MB, then 2048MB. (PHP version 8.2)

But although there is more RAM in the system, PHP allocates only less than 512MB of memory and gets stuck (apache not responding to any hit).

If I manually reset the php service, it starts working ok again.

I have some warnings on Apache error logs as below:

[Tue Nov 28 13:50:31.932468 2023] [http2:warn] [pid 13336:tid 139689031698112] [client 10.41.23.50:34858] h2_stream(13336-348-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:50:31.957119 2023] [http2:warn] [pid 718:tid 139687972828864] [client 10.41.23.50:60884] h2_stream(718-722-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:50:31.962808 2023] [http2:warn] [pid 13336:tid 139688492914368] [client 10.41.23.50:41472] h2_stream(13336-355-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:50:44.795327 2023] [http2:warn] [pid 13336:tid 139686882301632] [client 10.41.23.50:46130] h2_stream(13336-349-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:50:44.809696 2023] [http2:warn] [pid 718:tid 139688861996736] [client 10.41.23.50:38890] h2_stream(718-723-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:50:44.812757 2023] [http2:warn] [pid 13336:tid 139688467736256] [client 10.41.23.50:39320] h2_stream(13336-356-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:50:46.226529 2023] [http2:warn] [pid 13336:tid 139684701247168] [client 60.140.160.45:39332] h2_stream(13336-344-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:50:46.248903 2023] [http2:warn] [pid 718:tid 139688216086208] [client 60.140.160.45:50782] h2_stream(718-727-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:50:46.249496 2023] [http2:warn] [pid 13336:tid 139685238118080] [client 60.140.160.45:50370] h2_stream(13336-351-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:50:53.040321 2023] [http2:warn] [pid 718:tid 139686521579200] [client 10.41.23.50:38900] h2_stream(718-724-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:50:53.041629 2023] [http2:warn] [pid 13336:tid 139684743210688] [client 10.41.23.50:46146] h2_stream(13336-350-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:50:53.044637 2023] [http2:warn] [pid 13336:tid 139688989734592] [client 10.41.23.50:39324] h2_stream(13336-357-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:51:01.079480 2023] [http2:warn] [pid 718:tid 139685397513920] [client 60.140.160.45:47802] h2_stream(718-718-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:51:01.080906 2023] [http2:warn] [pid 13336:tid 139684709639872] [client 60.140.160.45:33486] h2_stream(13336-354-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:51:04.549895 2023] [http2:warn] [pid 13336:tid 139688476128960] [client 45.19.92.22:42392] h2_stream(13336-342-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:51:05.197461 2023] [http2:warn] [pid 718:tid 139686546757312] [client 10.41.23.50:50650] h2_stream(718-725-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:51:05.197938 2023] [http2:warn] [pid 13336:tid 139688998127296] [client 10.41.23.50:36250] h2_stream(13336-358-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:51:05.199445 2023] [http2:warn] [pid 718:tid 139688998127296] [client 10.41.23.50:58034] h2_stream(718-719-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:51:05.559879 2023] [http2:warn] [pid 13336:tid 139687964436160] [client 45.19.92.22:42398] h2_stream(13336-343-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Tue Nov 28 13:51:08.956464 2023] [http2:warn] [pid 13336:tid 139685254903488] [client 60.140.160.45:47810] h2_stream(13336-347-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
 

Attachments

  • Screen Shot 2023-11-28 at 14.14.43.png
    Screen Shot 2023-11-28 at 14.14.43.png
    28.5 KB · Views: 15
  • Screen Shot 2023-11-28 at 14.15.03.png
    Screen Shot 2023-11-28 at 14.15.03.png
    65.7 KB · Views: 12
I don't understand how any of this is related to PHP getting stuck. Stuck how? memory_limit is a setting for the maximum memory allowed to be allocated by a php process, not what you would expect to see allocated at any given time.
 
What I mean is Apache was not responding to anything. When I restart the PHP service, problems get solved.

I found out that, it was related to a network issue. Network bandwidth was overloaded for a period of time, and that was causing this issue.
 
What I mean is Apache was not responding to anything. When I restart the PHP service, problems get solved.

I found out that, it was related to a network issue. Network bandwidth was overloaded for a period of time, and that was causing this issue.

I am having the same problems. After the Directadmin update, PHP logs have these errors.

The website shuts down every 3 hours. When I restart PHP the problem is temporarily fixed. Then I have to do the same process again.

Is there a permanent solution?

Error Log:
[Fri Dec 08 04:20:55.110371 2023] [http2:warn] [pid 16860:tid 139713600022080] [client 162.158.163.92:27184] h2_stream(16860-40-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Fri Dec 08 04:20:55.114944 2023] [http2:warn] [pid 18188:tid 139712501102144] [client 162.158.251.155:33792] h2_stream(18188-22-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Fri Dec 08 04:20:55.152352 2023] [http2:warn] [pid 18188:tid 139713021187648] [client 172.70.43.82:41308] h2_stream(18188-38-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Fri Dec 08 04:20:55.153789 2023] [http2:warn] [pid 14564:tid 139713323193920] [client 162.158.78.83:61482] h2_stream(14564-13-1,CLEANUP): started=1, scheduled=1, ready=0, out_buffer=0
[Fri Dec 08 04:20:55.275762 2023] [http2:warn] [pid 13457:tid 139714145285696]
 
Do you have any extra load on your server before it stops responding? What is the screenshot of the top command? You can see it on the DirectAdmin panel too from Process Monitor.

If there is no load on top, you need to check the load on IO and Network. You may need to install some small software to monitor IO and Network loads.
 
I had similar issue for a while. It's very difficult to detect the problem. Mine was dns/network related. I have a few running php scripts in cron, and those scripts are accesing some feeds. Sometime the DNS from /etc/resolv.conf was not working well, and php processes got stuck wating for DNS resolver. After a while, the whole server got stuck. After setting a public dns server like 1.1.1.1 or 8.8.8.8 i had no issue anymore.

What is your current content for /etc/resolv.conf ?
 
I had the same issue even after dealing with network problems. It seems Directadmin lowered the php child process limit from 100 to 10 in new versions. Although I did not see any error related to the number of child processes on the error log, when I increased the child process limit, the problem was solved.

How to do it:

/usr/local/directadmin/directadmin set php_fpm_max_children_default 100
/usr/local/directadmin/custombuild/build rewrite_confs

This changes the child process limit to 100, but you can adjust it according to your needs, and the server's resources. If your PHP process is using 50MB, then 100 means around 5GB of memory. If you are using a VPS with low RAM, you may lower it, and if you have higher resources in a dedicated server, you may put a higher limit if your setup needs it.

If you check my first post, I said although there is more RAM on the machine, total PHP memory usage was set to around 500MB, this was because the child process limit was 10, and one process was using around 50MB.
 
Last edited:
Back
Top