I'm creating a service with php that returns json data from a table that contains 2100 rows. I'm using the following setup in dev:
我正在使用php创建一个服务,该服务从包含2100行的表中返回json数据。我在开发中使用以下设置:
- Xampp with Apache and MySql
- Windows 10
- PHP-7.0.8
使用Apache和MySql进行Xampp
With PDO in php to execute the query
用php中的PDO来执行查询
The service was working perfectly for both small requests (30 rows) and the entire table. I was calling it fairly often but had no problems. Recently it stopped working for requests that return the entire table and only works for the smaller requests.
该服务适用于小请求(30行)和整个表。我经常调用它但没有问题。最近它停止了返回整个表的请求,只适用于较小的请求。
I checked the Apache error logs and got the following:
我检查了Apache错误日志并得到以下信息:
[Sun Nov 20 11:06:06.687051 2016] [mpm_winnt:notice] [pid 4576:tid 536] AH00428: Parent: child process 11908 exited with status 1 -- Restarting.
[Sun Nov 20 11:06:06.687051 2016] [mpm_winnt:notice] [pid 4576:tid 536] AH00428:父:子进程11908退出状态1 - 重新启动。
[Sun Nov 20 11:06:06.889267 2016] [mpm_winnt:notice] [pid 4576:tid 536] AH00418: Parent: Created child process 924
[Sun Nov 20 11:06:06.889267 2016] [mpm_winnt:notice] [pid 4576:tid 536] AH00418:父级:创建子进程924
[Sun Nov 20 11:06:07.415857 2016] [ssl:warn] [pid 924:tid 436] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Nov 20 11:06:07.415857 2016] [ssl:warn] [pid 924:tid 436] AH01909:www.example.com:443:0服务器证书不包含与服务器名称匹配的ID
[Sun Nov 20 11:06:07.442378 2016] [mpm_winnt:notice] [pid 924:tid 436] AH00354: Child: Starting 150 worker threads.
[Sun Nov 20 11:06:07.442378 2016] [mpm_winnt:notice] [pid 924:tid 436] AH00354:Child:启动150个工作线程。
I have done a search for the solution although I am not sure what the issue is in order to search effectively. Each error message above appears to give me answers that do not relate to the issue I'm having (although, I'm not fully sure what the issue is).
我已经搜索了解决方案,但我不确定问题是什么,以便有效搜索。上面的每条错误消息似乎都给了我与我遇到的问题无关的答案(尽管我不完全确定问题是什么)。
Anyone know why something like this might happen?
任何人都知道为什么这样的事情会发生?
1 个解决方案
#1
1
My guess would be memory limitations (the children are being killed by the server). You can increase it but it won't solve the issue - what happens when you have 1 million records?
我的猜测是内存限制(孩子们被服务器杀死)。你可以增加它,但它不会解决问题 - 当你有100万条记录时会发生什么?
My advise is that you implement a pagination params and a max number of records to return:
我的建议是你实现一个分页参数和最多的记录返回:
http://website.com/api/v1/getUsers?position=0
http://website.com/api/v1/getUsers?position=100
http://website.com/api/v1/getUsers?position=200
etc..
This will drastically lower the stress on your system and enable the users to also lower their throughput in the event they only want the top x records, last 2, etc..
这将大大降低系统的压力,并使用户能够在他们只需要前x个记录,最后2个等的情况下降低吞吐量。
If you still want to be able to serve all, you can check this thread out to learn how to increase the memory for Apache: https://*.com/a/36920556/1935500
如果你仍然希望能够为所有人提供服务,你可以查看这个帖子以了解如何增加Apache的内存:https://*.com/a/36920556/1935500
#1
1
My guess would be memory limitations (the children are being killed by the server). You can increase it but it won't solve the issue - what happens when you have 1 million records?
我的猜测是内存限制(孩子们被服务器杀死)。你可以增加它,但它不会解决问题 - 当你有100万条记录时会发生什么?
My advise is that you implement a pagination params and a max number of records to return:
我的建议是你实现一个分页参数和最多的记录返回:
http://website.com/api/v1/getUsers?position=0
http://website.com/api/v1/getUsers?position=100
http://website.com/api/v1/getUsers?position=200
etc..
This will drastically lower the stress on your system and enable the users to also lower their throughput in the event they only want the top x records, last 2, etc..
这将大大降低系统的压力,并使用户能够在他们只需要前x个记录,最后2个等的情况下降低吞吐量。
If you still want to be able to serve all, you can check this thread out to learn how to increase the memory for Apache: https://*.com/a/36920556/1935500
如果你仍然希望能够为所有人提供服务,你可以查看这个帖子以了解如何增加Apache的内存:https://*.com/a/36920556/1935500