Forum Moderators: coopster

Message Too Old, No Replies

Dropped Connection?

         

SeanF

10:25 pm on Jan 13, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



Me again, LOL.

I think my PHP/MySQL, SaaS, business management application is dropping a connection, but I am not sure how to debug it.

I recently upgraded the entire suite, (hundreds of script files) from PHP5x to PHP7x and the problem seems to have started after the upgrade. The basic issue is as follows.

There is an "application" page which allows customers to apply for a certain number of "products". There are a number of steps in the process, and when the user completes the process there are a number of database "insert"s.
1. User / Customer information record is entered into one table
2. "Application" record are entered into another table
3. "Sales" record, referencing customer application is entered into another table
4. "Logistics" record is created in yet another table

Every once in a while I get an "application" but there is no "sales" record tied to it (One was never created, neither were the other downstream records). The only thing I can think of is that the function is being terminated / interrupted before it completes.

Similarly, when a user logs in to the system, they enter their username and password on the Login page. On the next page (License Agreement), they need to agree to the license terms. I have noticed on occasion that after agreeing to the license terms, the browser will display "can not connect to server". Refreshing the page takes the user back to the "License Agreement" page. Accepting the agreement again, proceeds to the correct page.

So, it appears that a connection may be dropping.

How do I figure out where or why? Is it a server issue? Could it be a programming issue? (It's not repeatable and works 95% of the time.)

Thank you.

w3dk

12:31 am on Jan 14, 2020 (gmt 0)

10+ Year Member Top Contributors Of The Month



The only thing I can think of is that the function is being terminated / interrupted before it completes.


As in a single PHP function? Are you using transactions?

So... it doesn't even attempt to "INSERT"? So it doesn't even "fail"? No error logged?

SeanF

4:04 pm on Jan 14, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



Thanks for the quick reply...

WRT you questions:

As in a single PHP function? Are you using transactions?
- Uhhh... I hate to say it, I am not sure what "transactions" are... I will do some research. If you can point me in the right direction, that would be helpful

So... it doesn't even attempt to "INSERT"? So it doesn't even "fail"? No error logged?
- One "INSERT" completes, the next does not. From anecdotal evidence, the customer reports a blank screen in the process so it would appear the script is simply terminating. This has probably happened only 5 times out of 215 "applications"

Perhaps related, very occasionally I get the following message when logging into the system, usually on the same page (License Agreement):
"Safari Can't open the Page
Safari can't open the page [address] because the server unexpectedly dropped the connection. This sometimes occurs when the server is busy. Wait for a few minutes and then try again"

The system is running on a Virtual Private Server and the RAM never seems overly loaded (2Gb RAM, 8Gb used of 60Gb D=Disk space). It's the only application running on the VPS and there are probably never more than a couple dozen users hitting it at any given time. Is there a way I can troubleshoot connectivity or server load?

Thanks tons for your insight.

lammert

11:23 pm on Jan 14, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Assuming you are on a Linux type system, the files in the /var/log directory may give a bunch of insight.

Did you install PHP 7 from a repository, or was it compiled from source? The new configuration may use up more memory in the VPS than the previous one and dependent on the VPS setup, processes may be killed in a random way to keep the core system running, without you ever knowing.

2GB RAM is somewhat an edge case for that. A badly tuned MySQL may use up so much memory that randomly the threshold for killing processes is reached. Many VPS hosters prefer settings in their VPSes where killing processes takes priority over swapping to disk, because killing processes only affects the abusing VPS, whereas swapping to disk may have an impact on all users.

Also, what type of VPS are you running on? For example, In KVM based systems the amount of RAM per VPS is guaranteed, whereas, in OpenVZ based systems, RAM is a shared resource for all VPSes. Because of shared resources, OpenVZ systems are cheaper with the same specs, but more prone to crashes because of noisy neighbors.

SeanF

4:14 pm on Jan 15, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



Thanks, Lammert.
I don't see a /var directory. Checking a "php.log" file, I see a fair number of "division by zero" errors, but these have to do with resizing an image file where a dimension value is zero (getimagesize() is returning a null value)... I can fix that but I don't think it's related.

The system is running in a hosted environment with a company called "DreamHost" It was running flawlessly on PHP5. PHP7 was installed by DreamHost, I simply select which build of PHP I want to use from a configuration menu. I can switch between builds at will.
Similarly, the VPS would have been configured by DreamHost... I assume they know what they are doing but that may be a poor assumption. They advised that 1Gb RAM would be sufficient but I opted for 2 just in case.
In any case, I don't have any knowledge of what type VPS it is or how it's configured.
Is there something I should ask their customer support to be checking for me

lammert

6:54 pm on Jan 15, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you are using a template provided by the hosting company, I assume that settings are well configured for the amount of resources available. AFAIK your hosting company stores databases on separate servers and is not running MySQL processes on the VPSes, so bulky or badly tuned databases should not have any impact on memory usage on the VPS.

The PHP log file only contains application messages. What you are looking for now is more like system log messages. Besides trying to search for log files on other locations, I ran out of ideas at the moment.