Connecting to Cloud SQL from App Engine is slower than connecting to localhost

So, I'm trying to connect to Google Cloud SQL from my Google App Engine. Everything works, but latency is very high. A simple selection request takes about 1.3 seconds. However, when I connect with localhost, it takes much less time. The difference in connection is as follows:

in engine yaml application

MYSQL_DSN: /cloudsql/instanceName
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: dbname

in App Engine php

$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);

when connecting to Cloud SQL in localhost I use:

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

localhost IP- Cloud SQL, ip- . , php localhost Cloud SQL, , App Engine. , ?

+4
1

, Cloud SQL asia-northeast1. Cloud SQL Issue 197. , , , .

(--), 2016 . . - Cloud SQL asia-northeast1. , , asia-east1 () , .

+2

Source: https://habr.com/ru/post/1663720/


All Articles