Does anyone else also run into high latency problem connecting to Cloud Sql?

151 views
Skip to first unread message

Andy Tseng

unread,
Dec 14, 2016, 8:47:06 AM12/14/16
to Google App Engine
So I am connecting to Second Gen Cloud SQL from my App Engine, and both of them are in the same project. However, the latency is really high, up to 1.3 seconds. So I was wondering if anyone else is also running into this problem. Everything works fine, but it's just the high latency and the same structure at AWS has a much shorter latency, so I was wondering why.

Les Vogel

unread,
Dec 14, 2016, 3:34:13 PM12/14/16
to google-a...@googlegroups.com
It should be only 1ms longer than 1st gen.  Are you sure that your deploy region for GAE Standard and your region for your 2nd get instance.  If not, that could add latency.

On Wed, Dec 14, 2016 at 2:17 AM, Andy Tseng <andyt...@gmail.com> wrote:
So I am connecting to Second Gen Cloud SQL from my App Engine, and both of them are in the same project. However, the latency is really high, up to 1.3 seconds. So I was wondering if anyone else is also running into this problem. Everything works fine, but it's just the high latency and the same structure at AWS has a much shorter latency, so I was wondering why.

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/35a830ee-b9bf-458d-bfc0-73fd31d0dcf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

  •  
Les Vogel
  •  Cloud Developer Relations
  •  le...@google.com
  •  +1-408-676-7023 

Nick (Cloud Platform Support)

unread,
Dec 16, 2016, 2:09:53 PM12/16/16
to Google App Engine
Hey Andy, 

It might depend on how you're connecting, using which kind of library in which language, and also possibly on how you're timing the query - whether you're looking at round-trip time including the query running, or just time to connect.

Cheers,

Nick
Cloud Platform Community Support

Nick (Cloud Platform Support)

unread,
Dec 20, 2016, 4:39:43 PM12/20/16
to Google App Engine
Hey Andy,

Let us know if you can get some of those details to us. We'd be happy to take a look into further investigating a possible cause.


Cheers,

Nick
Cloud Platform Community Support

On Wednesday, December 14, 2016 at 8:47:06 AM UTC-5, Andy Tseng wrote:

Andy Tseng

unread,
Dec 23, 2016, 3:11:43 AM12/23/16
to Google App Engine
Hey Nick, 

Sorry for the late reply, both my CloudSQL and App Engine are in the same project, which is located in northeast-asia. I am connecting through PHP using mysqli, and I've tried PDO and I am getting the same result. Interestingly, when I connect through host:port, I am getting a lot lower latency. I have whitelisted 0.0.0.0/0 for IP and using host:port connection and I am getting a pretty low latency (I know it's not secure). Which is weird, because unix socket should be a lot faster. Here is my code for both type of connection:

YAML :

MYSQL_DSN: /cloudsql/projectname:asia-northeast1:instancename 
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: dbname

Using socket:

$servername = getenv('MYSQL_DSN');
$username = getenv('MYSQL_USER');
$password = getenv('MYSQL_PASSWORD');
$dbname = getenv('MYSQL_DATABASE');
$connection = new mysqli(null, $username, $password, $dbname, null, $servername);

Using host:port  :

$servername = "ip.address:port";
$username = getenv('MYSQL_USER');
$password = getenv('MYSQL_PASSWORD');
$dbname = getenv('MYSQL_DATABASE');
$connection = new mysqli($servername, $username, $password, $dbname);

Please let me know if you can tell what's wrong! Thank you very much.

Andy Tseng

unread,
Dec 23, 2016, 3:15:18 AM12/23/16
to Google App Engine
Hey Les Vogel,

Please see my reply, I am using php and my GAE and CloudSQL are both in the same project, so that shouldn't be the reason! If you have any idea, please let me know! 

Thanks


On Thursday, December 15, 2016 at 4:34:13 AM UTC+8, Les Vogel wrote:
It should be only 1ms longer than 1st gen.  Are you sure that your deploy region for GAE Standard and your region for your 2nd get instance.  If not, that could add latency.
On Wed, Dec 14, 2016 at 2:17 AM, Andy Tseng <andyt...@gmail.com> wrote:
So I am connecting to Second Gen Cloud SQL from my App Engine, and both of them are in the same project. However, the latency is really high, up to 1.3 seconds. So I was wondering if anyone else is also running into this problem. Everything works fine, but it's just the high latency and the same structure at AWS has a much shorter latency, so I was wondering why.

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Message has been deleted
Message has been deleted

Adam (Cloud Platform Support)

unread,
Dec 25, 2016, 6:04:50 PM12/25/16
to Google App Engine
Hi Andy,

I've been able to reproduce this myself as well and an issue has been filed on the googlecloudsql issue tracker by another user, which we'll update once we have more info.

Andy Tseng

unread,
Dec 26, 2016, 10:51:26 PM12/26/16
to Google App Engine
Thank you very much Adam, please let me know if there is any updates! :)

Nick (Cloud Platform Support)

unread,
Dec 28, 2016, 9:53:37 PM12/28/16
to Google App Engine
Hey Andy,

Thanks for that information. I'm currently working on reproducing the behaviour, although I'm not seeing it so far. It may be related to the App Engine app's location. Are you sure your app's instances are in asia-northeast1?

Also, this is speculation and I'll have to confirm, but perhaps there's something odd happening with the resolution of the SQL instances' location / routing of packets when using the unix socket (which is of course an abstraction rather than a mere socket to a db process running on the local "machine") while the more direct IP route is avoiding that. 

I'll get back to you as soon as I can with more clarity on this. In the meantime, it's good to know the IP workaround is efficient.


Cheers,

Nick
Cloud Platform Community Support

Andy Tseng

unread,
Dec 29, 2016, 11:07:21 PM12/29/16
to Google App Engine
Hey Nick,

So Adam (also from Cloud Platform Support) was able to reproduce the problem. It seems like it has something to do with the location of the project. My whole project is located at asia-northeast1 so it probably has something to do with that location not being able to run socket connection fast enough. If you also have any updates, please let me know. Thank you!

Nick (Cloud Platform Support)

unread,
Dec 30, 2016, 4:23:44 PM12/30/16
to Google App Engine
Hey Andy,

Glad to hear it's being tracked. That would be the correct place to follow up for updates.


Cheers,

Nick
Cloud Platform Community Support

Reply all
Reply to author
Forward
0 new messages