zyeek
zyeek

Reputation: 1287

Google App Engine logs a mess of New connection for ... and Client closed local connection on

Checking out my logs on my App Engine. I get A LOT of

New connection for "<project_id>-central1:<project_name>"
Client closed local connection on /cloudsql/<project_id>-central1:<project_name>/.s.PGSQL.5432 

Like happening multiple times a second and just floods my logs.

I was unable to find any information relating to this and maybe this is just a non-issue.

I am using Django on the app engine.

Upvotes: 12

Views: 4071

Answers (4)

C. S. F. Junior
C. S. F. Junior

Reputation: 341

Changing CONN_MAX_AGE value to None can help, however this may expose your application to bot attacks like exposed me (see the picture below):

Google Cloud Platform

Looking for the IP's in abuseIPDB.com I've found a lot of reports of Brute Force/Web App Attack from it.

Maybe setting the variable value to a fixed number may keep your application safe and stop these logs.

Upvotes: 0

FireGnome
FireGnome

Reputation: 130

I'm not a django developer but I guess the root of this problem is that django opens a new connection to the database for every request by default.

Source: https://docs.djangoproject.com/en/2.1/ref/databases/

Persistent connections avoid the overhead of re-establishing a connection to the database in each request. They’re controlled by the CONN_MAX_AGE parameter which defines the maximum lifetime of a connection. It can be set independently for each database.

The default value is 0, preserving the historical behavior of closing the database connection at the end of each request. To enable persistent connections, set CONN_MAX_AGE to a positive number of seconds. For unlimited persistent connections, set it to None.

You can try to increase the CONN_MAX_AGE or set it to None and the log messages should disappear.

Upvotes: 0

Federico Panunzio
Federico Panunzio

Reputation: 964

I found this post where it's mentioned that setting -verbose=false will turn off the new/closed connection logs.

Upvotes: 2

Rub&#233;n C.
Rub&#233;n C.

Reputation: 1098

I found information about the same error but it wasn't generating a lot of connections. Anyway it was related to the Cloud SQL proxy.

Have you followed the instructions in this guide to configure the PostgreSQL connection to App Engine? I am particularly interested in the ones from "Setting up your local environment".

I did not found any related field in quotas or pricing pages but you can check the billing in the Google Cloud Console: Billing -> Overview -> [PROJECT_ID].

Upvotes: 0

Related Questions