Review Cloud SQL SQL Server connection limits

Set connection limits suited to expected load and instance capacity.

Description

If SQL Server user connections is lower than the concurrency a workload needs, new connections can be rejected. An explicit limit can also be an intentional overload control; 1000 is not inherently an incorrect value.

0 selects dynamic adjustment up to 32767, not unlimited connections. Instance resources and application constraints still limit actual capacity.

Potential impact

  • An overly low limit can block legitimate requests and administrative access.
  • Raising the limit without capacity planning can increase resource use and latency.

Remediation

  • Choose user connections after reviewing concurrent usage, connection pools and instance capacity. Use 0 when dynamic adjustment is appropriate, and plan the required restart.
  • Load-test legitimate connection capacity and overload controls, and monitor connection failures and resource usage.

Examples

These excerpts compare part of the instance settings. Use a supported engine version and SQL Server machine type, and supply var.sql_server_tier and omitted required inputs. Changing this flag does not require the engine-version change shown in the examples.

Before

hcl
resource "google_sql_database_instance" "db" {
  name             = "sqlserver-instance"
  database_version = "SQLSERVER_2017_EXPRESS"
  region           = "us-central1"

  settings {
    database_flags {
      name  = "user connections"
      value = "1000"
    }
  }
}

After

hcl
resource "google_sql_database_instance" "db" {
  name             = "sqlserver-instance"
  database_version = "SQLSERVER_2019_STANDARD"
  region           = "us-central1"

  settings {
    tier = var.sql_server_tier

    database_flags {
      name  = "user connections"
      value = "0"
    }
  }
}

Explanation:

  • Before: The connection limit is 1000. Assess whether it matches workload and capacity needs.
  • After: 0 selects dynamic adjustment. It does not provide unlimited connections or resources.

References