简体   繁体   中英

Google Cloud sql database connection error in java hibernate

I am using Google Cloud SQL using machine type of db-f1-micro for a project deployed on Google App Engine in Standard Environment(JAVA). Sometimes, I got below error while connecting with database. This scenario happens when open same page in multiple tabs at the same time(load/performance testing).

Source code used in project from https://github.com/GoogleCloudPlatform/appengine-cloudsql-native-mysql-hibernate-jpa-demo-java

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)

The metrics from app engine log for error and mysql usage. You can easily see that mysql active connection usage is below 100%.

在此处输入图片说明

在此处输入图片说明

Please suggest what wrong I am doing?

From https://cloud.google.com/appengine/docs/standard/java/cloud-sql/pricing-access-limits

"Each App Engine instance cannot have more than 12 concurrent connections to a Google Cloud SQL instance."

How many requests are sending to App Engine and how many connections does the app instance open for each of those requests ?

Looks like this thread is old but we have this problem in our test environment. It happens frequently and repeatedly after our GAE test system is not used for a while. The first time someone tries to access the app we get one or two of these.

I assume it has something to do with GAE ramping up a server instance. Although I'm not sure why this happens with the db. I don't think we have any connection pooling (specifically because GAE can make our app go dormant).

And with the app just starting up, we can't be exceeding any connection limits.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM