>我在谷歌应用程序引擎上运行Spring启动应用程序,前几天应用程序崩溃导致应用程序重新启动。 查看日志,我注意到应用程序不断反复连接到我的Google sql postgres数据库。
查看数据库中的日志,我可以看到我在数据库上有 60 个连接。我使用 JDBC url 简单地连接到带有云 sql-jdbc-socket-factory 的数据库: dbc:postgresql://google/{databaseName}?useSSL=false&cloudSqlInstance={instanceUrl}&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user={user}&password={password}
显示的日志包括:
A 2019-04-11 14:57:01.674 INFO 1 --- [onnection adder] c.g.cloud.sql.core.SslSocketFactory : Connecting to Cloud SQL instance [{instance url}] on IP [{ip adress}].
A 2019-04-11 14:58:11.458 INFO 1 --- [onnection adder] c.g.cloud.sql.postgres.SocketFactory : Connecting to Cloud SQL instance [{instance url}] via ssl socket.
A 2019-04-11 14:58:11.460 INFO 1 --- [onnection adder] c.g.cloud.sql.core.SslSocketFactory : Connecting to Cloud SQL instance [{instance url}] on IP [{ip adress}].
A 2019-04-11 14:58:22.878 INFO 1 --- [onnection adder] c.g.cloud.sql.postgres.SocketFactory : Connecting to Cloud SQL instance [{instance url}] via ssl socket.
A 2019-04-11 14:58:22.880 INFO 1 --- [onnection adder] c.g.cloud.sql.core.SslSocketFactory : Connecting to Cloud SQL instance [{instance url}] on IP [{ip adress}].
A 2019-04-11 15:01:56.477 INFO 1 --- [onnection adder] c.g.cloud.sql.postgres.SocketFactory : Connecting to Cloud SQL instance [{instance url}] via ssl socket.
A 2019-04-11 15:01:56.479 INFO 1 --- [onnection adder] c.g.cloud.sql.core.SslSocketFactory : Connecting to Cloud SQL instance [{instance url}] on IP [{ip adress}].
A 2019-04-11 15:02:08.108 INFO 1 --- [onnection adder] c.g.cloud.sql.postgres.SocketFactory : Connecting to Cloud SQL instance [{instance url}] via ssl socket.
建议应用引擎中的项目至少具有 Ram 2 GB 以避免连接错误,您可以在此 URL 中查看任何代码问题:https://cloud.google.com/sql/docs/postgres/connect-external-app。