Solved

PHP latency when connecting to remote database

Posted on 2014-04-06
4
455 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 109

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 109

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

777 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