Monday, May 16, 2022

[google-cloud-sql-discuss] Re: Recommended cloud sql postgresql client settings

Do you see an improvement if you use the default connection amount limits, according to what is recommended from the documentation? The documentation also describes this error being caused by connection timeouts, have you found better results by increasing the connection life?

On Friday, May 13, 2022 at 6:31:53 PM UTC-5 r...@transcarent.ai wrote:
Yes.

We defined the instance creation in terraform as:

resource "google_sql_database_instance" "postgres" {
  name = "prefix-postgres"
  database_version = "POSTGRES_13"
  deletion_protection = true

  settings {
    tier = "db-custom-4-15360"

    disk_autoresize = true
    disk_size = 200
    disk_type = "PD_SSD"

    activation_policy = "ALWAYS"
    availability_type = "REGIONAL"

    backup_configuration {
      enabled = true
      start_time = "07:00"
      location = "us"
      transaction_log_retention_days = 7
      point_in_time_recovery_enabled = true
      backup_retention_settings {
        retained_backups = 365
        retention_unit = "COUNT"
      }
    }

    database_flags {
      name = "cloudsql.enable_pgaudit"
      value = "on"
    }

    database_flags {
      name = "pgaudit.log_parameter"
      value = "on"
    }

    database_flags {
      name = "cloudsql.logical_decoding"
      value = "on"
    }

    ip_configuration {
      ipv4_enabled = false
      dynamic "authorized_networks" {
      }
        require_ssl = true
    }

    maintenance_window {
      day = 7
      hour = 8
    }
  }

  lifecycle {
    ignore_changes = [
      settings[0].disk_size
    ]
  }
}

On Thursday, May 12, 2022 at 4:50:07 PM UTC-4 fiescocasasola wrote:

Did you follow Google's documentation to setup the postgresql instance? If you use Google's documentation, can you share it please?  The recommended settings are always part of Google's documentation. 


Here is a google document to create a  PostgreSQL instance [1]


[1]:https://cloud.google.com/sql/docs/postgres/create-instance

On Wednesday, May 11, 2022 at 4:26:36 PM UTC-5 r...@transcarent.ai wrote:
We have a postgresql v13 instance where we get occasionally "connection reset by peer" errors.

We are not using the Cloud SQL Auth proxy.

Code is in golang and using pgx driver with database/sql Interface.

For each client, we have a max connection of 20, a max idle connection of 5, and max connection life time of 5 minutes.

We are deploying multiple clients with these settings. Looking in in the graph of active connections, we have a max of 500 and in the last week have a max active connection of 14.

Are there some recommend settings that we should be using to prevent us from getting these 
 occasional "connection reset by peer" errors?

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/0b59b5eb-0d79-4f5c-ba9e-751ad63b6e95n%40googlegroups.com.

No comments:

Post a Comment