Matthew Lee Matthew Lee - 21 days ago 6
Apache Configuration Question

PHP Unable to retrieve large requests

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:


  • Xampp with Apache and MySql

  • Windows 10

  • PHP-7.0.8



With PDO in php to execute the query

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.

I checked the Apache error logs and got the following:

[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.889267 2016] [mpm_winnt:notice] [pid 4576:tid 536] AH00418: Parent: Created child process 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.442378 2016] [mpm_winnt:notice] [pid 924:tid 436] AH00354: Child: Starting 150 worker threads.

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?

Answer

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?

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

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: http://stackoverflow.com/a/36920556/1935500