Solved

PHP latency when connecting to remote database

Posted on 2014-04-06
4
452 Views
Last Modified: 2014-04-15
Hello,

We were wondering if latency in connecting to a remote database with PHP would slow down the user experience. For example:

1) User submits a PHP form hosted on a CDN server located close to them
2) PHP script passes the collected data from the form to a centralised database hosted in a different datacenter (approx 120 ms latency from CDN server)

Would PHP hold up the user experience because it would be waiting on a 200 response from the database server Or would the latency only exist between the CDN and Database server?
0
Comment
Question by:PlumInternet
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
bigeven2002 earned 167 total points
ID: 39982101
Hello,

PHP stays running until the script is finished so that includes waiting for the 200 OK response since it is part of the database php command.  While in most cases 120 ms will go unnoticed, technically it can slow down the experience in this 3 Tier setup.
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 167 total points
ID: 39982191
All the PHP methods I know of will wait for a text response.  Maybe if you're doing 'socket' programming it might know about the 200 response.  Otherwise, PHP waits for the return data.
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 166 total points
ID: 39982688
Absent some extraordinary API programming, PHP will wait.  But it is (a little bit) application-dependent.  If the PHP application was "write only" and did not need any information back from the DB server, it could, in theory, start an asynchronous process to write to the DB server and PHP could continue its operation without further reference to the DB server.  In practice this is very rare; most programmers would expect a success or fail signal back from the DB server and if such a signal is required PHP would need to wait until it was received.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40002020
What was wrong with the answers?  Please see the grading guidelines and tell us what you were expecting that you did not get, thanks.
http://support.experts-exchange.com/customer/portal/articles/481419
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task of choosing a web design company to build a website for your business should never be taken in a light manner. Provided the fact that your website will act as a representative to your business and will be responsible for imposing an online …
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now