Hello
We are looking the option to to use Google Cloud SQL servers, but on the initial testing phase we are strugling how the connection making itself to the instance can be so low compared to instances running on local mahcine. Currently our production servers has mysql running on same instance where apache itself is and all the comparing is made against this perspective.
We aim to run our code on Docker containers and hoping to move Cloud Run
Cloud instance is on same country (Finland) and there is 2vCPU and 8gigs ram on it. There is no difference do I use Public IP, Private IP or socket connections on when making test on Cloud Run.
Using the Public IP from my local machine is also as slow, also with or without using Auth Proxy.
I have now benchmarked making 100 mysql connections on php on for loop and timing that.
$page_start = microtime(true);
$dbc = new DBC();
$tot_start = microtime(true);
$before_con = microtime(true);
for($i = 0; $i<100 ; $i++) {
$dbc->connect();
$after_connected = microtime(true);
echo "Connected in time of: ". round($after_connected-$before_con,5) ." seconds <br>";
$dbc->close();
$before_con = microtime(true);
}
$tot_end = microtime(true);
echo "total time: ". round($tot_end-$tot_start,5) ." seconds <br>";
Test Run on Cloud Run against Google Cloud SQL server instance: (part of the results)
MySQL socket connection / private ip same results
Connected in time of: 0.01384 seconds
Connected in time of: 0.01249 seconds
Connected in time of: 0.01057 seconds
Connected in time of: 0.0218 seconds
Connected in time of: 0.01704 seconds
Connected in time of: 0.01184 seconds
Connected in time of: 0.01108 seconds
Connected in time of: 0.01097 seconds
total time: 1.56648 seconds (100 x connection)
Test run on local docker against localhost mysql server on docker
Connected in time of: 0.00109 seconds
Connected in time of: 0.00092 seconds
Connected in time of: 0.00078 seconds
Connected in time of: 0.00086 seconds
Connected in time of: 0.00075 seconds
Connected in time of: 0.00065 seconds
Connected in time of: 0.0008 seconds
Connected in time of: 0.00055 seconds
total time: 0.06576 seconds (100 x connection)
Is this connection time just to be accepted or is there something we could do to improve it? Our product is ERP/reporting system, what makes lots of connections and with such a lag there basically is no usability when normal functions takes ages to complete. Comparing some report loading times , when on localhost report takes 1.5 seconds it takes 10-20 seconds on Cloud Run.