PHP Unable to retrieve large requests - php

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?

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

Related

Running Laravel on local machine

I am trying to run a laravel project in my local machine. It starts normally on http://127.0.0.1:8000 but when I try to open the url in the browser the port changes to 8001 and the new url is http://127.0.0.1:8001. When I try to open this in the browser, again the port changes to 8002.
Image showing the issue
composer.json
My PHP version is 7.4.1. If anyone else faced this issue earlier or knows how to fix this issue, please help in fixing this issue.
Thank you.
Update 1:
Noticed something. Whenever database related code is executed, this issue is popping up. For example, when I try to execute the following code shown in the image, it runs smoothly and I can see the output in the browser. Case when the code runs smoothly
But when I change the code to the following, the issue shows up.
Case when the issue shows up. This is not any database heavy query but why this issue? Any leads would be very helpful.
Update 2:
Found nothing in laravel logs but found the following in the apache error log which is given below:
[Thu Jun 09 21:37:24.988703 2022] [mpm_winnt:crit] [pid 2660:tid 704] AH02538: Child: Parent process exited abruptly. Child process is ending
[Thu Jun 09 21:37:27.399609 2022] [core:warn] [pid 8084:tid 576] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00455: Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.4.1 configured -- resuming normal operations
[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00456: Apache Lounge VC15 Server built: Aug 11 2019 12:20:04
[Thu Jun 09 21:37:27.446479 2022] [core:notice] [pid 8084:tid 576] AH00094: Command line: 'c:\xampp\apache\bin\httpd.exe -d C:/xampp/apache'
[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00418: Parent: Created child process 10064
[Thu Jun 09 21:37:28.196453 2022] [mpm_winnt:notice] [pid 10064:tid 664] AH00354: Child: Starting 150 worker threads.
Try this parameter I think help you
php artisan serve --port=8080
This highly, might be a problem to the code, you've write-ed, not a Laravel problem. I've faced issues like this before for a long time ago, so you might check :
The code is processing in blade or controller.
Or it might be a memory issues related to PC (might not be, related to this issue, but i had a lots of memory issues back then when i had low-end PC and all these issues was happening.)
As I said, my first guess is the code, so you might need to share the code find out, what is happening.
Also conflicts in reserved ports will be avoided anyway, for example if you set your local environment server to something else(8080), same issue will happen again.
And sometime if you close your terminal without closing local environment, new php artisan serve will run the local environment anyway, for example, my terminal/IDE was closed but application was serving, and doing php artisan serve not forced me to close and run a new local environment like yours, it was trying to serve again, but old one was doing conflicts.
So as I said again, it might be a code issue.
Double check your code or share it to find the issue.

Too many MySQL connections on WordPress

I install word-press on my Ubuntu server. I only have 3 blog post but it reach max_connection within hour.So whenever my user kit my blog it's show database establish error. my log file have following entry
server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
[Mon Jun 20 06:30:21.877663 2016] [mpm_prefork:notice] [pid 43436] AH00169: caught SIGTERM, shutting down
my default max_connection is 200 now i increase it to 1024.

Apache error log: zend_mm_heap corrupted, child process exited with status 1 -- Restarting

I have seen some topics about 'zend_mm_heap' corrupted and 'child process exited with status nnnnn' but none of this topics lead to a solution. What does status 1 means in clear text, it is not clear what exactly happen.
Symptoms
This problem does not occur when the site is running without being logged in. Only when I logged in the problem sometimes happen when refreshing the page. Strange is that sometimes the html fails to load and sometimes resources like a CSS file or JS file. I also have seen that some resources take 6 seconds to 10 seconds to load. I think this is caused by restarting the server because of this error.
When above symptoms occur, the following (similar) info is written to the error.log file:
Error in error.log file:
zend_mm_heap corrupted
[Sun Feb 09 03:56:57 2014] [notice] AH00428: Parent: child process exited with status 1 -- Restarting.
[Sun Feb 09 03:56:57 2014] [notice] AH00455: Apache/2.4.3 (Win64) configured -- resuming normal operations
[Sun Feb 09 03:56:57 2014] [notice] AH00456: Server built: Aug 18 2012 14:13:48
[Sun Feb 09 03:56:57 2014] [notice] AH00418: Parent: Created child process 3460
[Sun Feb 09 03:56:57 2014] [notice] AH00354: Child: Starting 64 worker threads.
Configuration:
Intel I7 (Quadcore) chipset, 16GB RAM
Running latest XAMMP (or Z-WAMP, in both the same problem - see for Z-WAMP also http://zwamp.sourceforge.net/) on Windows 7 64 bit
Running APC -
For example:
Normal feedback (when problem does not occur):
What I want to know
Does have somebody info about Apache status 1 exit?
Am I able to debug this, how can I debug this?
There is a problem with APC (I use version 1.3.1) that cause this error, corrupt memory for some reason. I believe it has something do with session data because the problems only occur when logged in. My PHP class uses only a session when it is required to be logged in to be able to view the page. I have also checked my code but there is nothing abnormal or incomplete.
When I turn off the Windows extension php_apc.dll in the php.ini file everthing is working fine. No memory corruption and no delays. Also tried other cache extensions like xCache, eAccelerator, memcache and loads normally.
So I qualify this as a bug.

Server truncates/interrupts output when request comes from external computer, but not from 127.0.0.1

Setup:
EasyPHP Dev server 13.1VC11 (Apache 2.2.4, MySQL 5.6.12, PHP 5.5.0)
Windows 7.
Apache is set up with multiple virtual hosts each pointing to a separate folder under ...data\localweb\.
Server also acts as a gateway between internet and local network.
My wife has made a webpage which includes JavaScript and jQuery and PHP.
When I open a browser on my server computer and access the pages, everything works as they should. Via both these addresses:
http://127.0.0.1/liselotte/projekt5/2vs.php
http://liselotte.mine.nu/projekt5/2vs.php
However, when I try to access the page from another computer on my local network, the two longer pages in my wife's project gets truncated. (file 2vs.php, also accessible on the page's main menu as "V/S") It always gets truncated at the same place, in the middle of a 8-letter word, in a piece of HTML formatted text.
I use Firefox and can see when the code cuts off before the browser displays an error message that "transfer was aborted". (It's in Swedish, so I'm a bit uncertain about the exact wording of the message) "The connection to the server was severed during retrieval of the page". (no HTTP-error number)
I have also tried Internet Explorer and Chrome, transfer is cut off at the exact same place every time.
Weirdly enough, the page seems to work when accessed from internet.
The Apache config file contains
Listen 127.0.0.1:80
Listen trilliadin.mine.nu:80 #which is one of the virtual hosts
Listen 192.168.137.1:80 #which is Windows local address assigned to my LAN
I've tested disabling all firewalls, but no difference.
I dumped about 4MB text into a file.html to see if this also gets truncated but the whole text-file gets transferred.
Does anyone recognize these symptoms?
EDIT:
Regarding error-reporting... I do get some weird apache-errors when I start the server.
[Wed Jan 15 21:13:37.989659 2014] [mpm_winnt:notice] [pid 968:tid 424] AH00424: Parent: Received restart signal -- Restarting the server.
Failed loading D:\EasyPHP\binaries\php\php_runningversion\php_xdebug-2.2.2-5.4-vc9.dll
PHP Warning: PHP Startup: in Unknown on line 0
[Wed Jan 15 21:13:39.861663 2014] [mpm_winnt:notice] [pid 968:tid 424] AH00455: Apache/2.4.4 (Win32) PHP/5.5.0 configured -- resuming normal operations
[Wed Jan 15 21:13:39.861663 2014] [mpm_winnt:notice] [pid 968:tid 424] AH00456: Server built: Apr 8 2013 13:46:39
[Wed Jan 15 21:13:39.861663 2014] [core:notice] [pid 968:tid 424] AH00094: Command line: 'D:\\EasyPHP\\binaries\\apache\\bin\\apache.exe -d D:/EasyPHP/binaries/apache'
[Wed Jan 15 21:13:39.861663 2014] [mpm_winnt:notice] [pid 968:tid 424] AH00418: Parent: Created child process 5240
[Wed Jan 15 21:13:40.017663 2014] [mpm_winnt:notice] [pid 5328:tid 436] AH00364: Child: All worker threads have exited.
Failed loading D:\EasyPHP\binaries\php\php_runningversion\php_xdebug-2.2.2-5.4-vc9.dll
PHP Warning: PHP Startup: in Unknown on line 0
[Wed Jan 15 21:13:41.655666 2014] [mpm_winnt:notice] [pid 5240:tid 432] AH00354: Child: Starting 64 worker threads.
But I don't understand what it means. Tonight, the Virtual Host liselotte.mine.nu became unresponsive, while virtual host trilliadin.mine.nu continued working. The problem resolved when I restarted the apache server. (see error log above)

Performance issue with php/apache/windows. Connection reset

I'm having a rather big problem with a site performance. It's a php site on Apache on Windows Server 2003.
Web site is basically crashing with 'connection was reset' or 'cannot load web page' quite often. httpd process in Windows takes about 100mb on normal traffic, having about 1gb of memory still free
This is first time I host a php site on Windows (WIndows was requirement in this case) and I'm not sure what are my options
Thanks
Apache log is displaying the following (sorry for pasting it like that, couldn't do it as 'code block' from some reason. This surely doesn't look right. Any ideas what could be going on?
[Tue Nov 08 16:44:43 2011] [notice] Parent: Received restart signal --
Restarting the server.
[Tue Nov 08 16:44:43 2011] [notice] Child 2072: Exit event signaled.
Child process is ending.
httpd.exe: Could not reliably determine the server's fully qualified
domain name, using 192.168.67.1 for ServerName
[Tue Nov 08 16:44:44 2011] [notice] Apache/2.2.17 (Win32)
mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.2.17 configured -- resuming normal
operations
[Tue Nov 08 16:44:44 2011] [notice] Server built: Oct 18 2010 01:58:12
[Tue Nov 08 16:44:44 2011] [notice] Parent: Created child process 7692
httpd.exe: Could not reliably determine the server's fully qualified
domain name, using 192.168.67.1 for ServerName
httpd.exe: Could not reliably determine the server's fully qualified
domain name, using 192.168.67.1 for ServerName
[Tue Nov 08 16:44:44 2011] [notice] Child 2072: Released the start
mutex
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Child process is
running
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Acquired the start
mutex.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting 1000 worker
threads.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting thread to
listen on port 2090.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting thread to
listen on port 8011.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting thread to
listen on port 8080.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting thread to
listen on port 443.
[Tue Nov 08 16:44:44 2011] [notice] Child 7692: Starting thread to
listen on port 80.
[Tue Nov 08 16:44:45 2011] [notice] Parent: child process exited with
status 0 -- Restarting.
httpd.exe: Could not reliably determine the server's fully qualified
domain name, using 192.168.67.1 for ServerName
Windows event viewer is throwing the following
Error - VsJITDebugger. An unhandled win32 exception occurred in httpd.exe [4416]. Just-In-Time debugging this exception failed with the following error: Debugger could not be started because no user is logged on.
Can anyone help with this?
That '[notice] Parent: child process exited with status 0 -- Restarting' is describing the issue here. Tho it describes it in vary vague way. Server is basically restarting on it's own every few minutes. I took the site down with a holding page and the error and restart ddidn't occure. I added an html page and bombed it with combinations of requests using AB. It would always crash at requests close to number of ThreadsPerChild specified in mpm config, which I have set to 1000. Each crash followed with an error
apr_socket_recv: An existing connection was forcibly closed by the remote host.
(730054)
That error only displays when benchmarking. Nothing like that appears in apache log. As soon I switch the site back live, it starts to crash every few minutes. The site generates about 100 requests per page and is also using 2-3 ajax calls per page (while loading)
I spent hours searching the web for possible solutions. Found nothing that fits. I'm completely out of options. I'm not even experienced running apache on windows as during 5 years I work in the business I never had to run php sites on Windows. I haven't seen such error on linux neither
There are two places where you should have a look:
Regular Apache logs, located in the logs folder inside Apache installation.
Windows event viewer, located in Windows control panel
In particular, the second one will log Apache crashes and will possibly reveal additional details.

Categories