ahphpnz Posted January 23, 2015 Share Posted January 23, 2015 Hi All, I'm hoping somebody would be able to help me with a performance issue I'm having with a bit of code I've written. The setup: Client request arrives on Apache2 reverse proxy over HTTPS. SSL is offloaded and proxy initiates connection to backend development web server over standard HTTP. The website is being developed using HTML5 syled with CSS, Javascript (to dynamically show counters on message text area, perform client side validation for browsers that do not support the build in HTML5 input validation) and PHP for server side validation and form submission (sends email to webadmin). The development web server is located in a LXC container on the production web server. The host server presents the "public" IP address to the physical network and uses UFW to NAT all traffic inbound and outbound from the development website to trick the network into thinking that the server is on the physical network (Only way to get it routeable across the rest of the network). The problem: On form submission, if I intentionally leave the fields blank and turn off client side validation, the script echos "An error occured in your form, please check to make sure that all relevent fields are filled in!!!". This response returns in 16.50ms with a latency of 34.92ms. The POST appears instantly in the Apache2 logs less than a second after I submit the form. If I submit the form with all fields (Name, Email, Phone, Website, Subject and Message), it takes 60 - 65 seconds before Apache logs the POST has arrived. I'm not entirely sure why its taking this long for the server to receive the content. GET Requests are pretty much instant as I would expect. Could this be an issue with inefficient scripting that maye be causing this type of delay? This issue occurs regardless of whether I use firefox or Safari. Could this be a result of inefficient scripting? Using timelines in Safari and on form submission with content, I get 1.0min latency with an actual duration/script run time of 5.336ms. Where would this latency be coming from? Standard GET requests for HTML and CSS content is instant, next to no latency but once the Payload increases in size, it seems like I run into the issue. Any views, thoughts or possible things to try would be hugely appreciated. I'm learning the ropes with scriping at the moment but this high latency, as a hunch, appears to be server related. Happy to upload the submit.php script and web form if it will help. Many Thanks, A Quote Link to comment https://forums.phpfreaks.com/topic/294187-php-script-execution-delays/ Share on other sites More sharing options...
scootstah Posted January 23, 2015 Share Posted January 23, 2015 If it's taking that long to arrive to Apache, then it seems like a network issue. It hasn't even reached your script yet. Quote Link to comment https://forums.phpfreaks.com/topic/294187-php-script-execution-delays/#findComment-1504014 Share on other sites More sharing options...
ahphpnz Posted January 24, 2015 Author Share Posted January 24, 2015 I'm not convinced, why would standard HTTP GET requests be instant yet a POST with content is rediculously delayed. Seems like there is some major processing delay on the client side before it sends the POST out on the wire. TCP connections to all other services internal and external are fine, its just this development web service that has the issue and it only occurs when sending a POST with content. A POST with no form data (other than blank fields) arrive instantly on the server so that appears to be a client side issue. I've tried from multiple clients and its the same issue. I've never seen an issue like this, it's not making a lot of sense. Surely this couldn't be a network issue if everything else is functioning as expected with no latency/delay? Quote Link to comment https://forums.phpfreaks.com/topic/294187-php-script-execution-delays/#findComment-1504050 Share on other sites More sharing options...
ahphpnz Posted January 24, 2015 Author Share Posted January 24, 2015 So I have eliminated the code as being the issue by moving the code on to the Production host outside of the LXC container. The processing issue is either server side or on the interconnect between the Host and the container. This forum isn't the best place to tackle the root cause of the issue, at least PHP/Inefficient coding has been ruled out. I'll mark this as either a OS or Networking fault on the server side and rule out PHP as root cause. Works a charm outside of the container. Quote Link to comment https://forums.phpfreaks.com/topic/294187-php-script-execution-delays/#findComment-1504058 Share on other sites More sharing options...
kicken Posted January 24, 2015 Share Posted January 24, 2015 Apache writes the access log entry after the request has finished, so something in the code delaying the request would also delay the log entry. It sounds like this is what you're seeing? There could be some kind of networking issue such as apache or the code trying to connect to an external resource and failing. If the delay is fairly constant (for example always about 60 seconds) then I'd suspect this kind of problem. 60 seconds is PHP's default socket timeout, and is a relatively common default timeout for other things. Quote Link to comment https://forums.phpfreaks.com/topic/294187-php-script-execution-delays/#findComment-1504071 Share on other sites More sharing options...
ahphpnz Posted January 27, 2015 Author Share Posted January 27, 2015 Kicken, you raise a very valid point. I'll drop the code back in on the develoment server within the container with the google captcha code enabled and see if I see the same result. Likewise I'll also disable it after the fact and post the results. This might come in handy for others if they stumble across it. Completely missed that! Will post back here to validate that this was the beahaviour that was experienced. Quote Link to comment https://forums.phpfreaks.com/topic/294187-php-script-execution-delays/#findComment-1504321 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.