When we decided to self-host Supabase on GCP, the database choice was easy: Cloud SQL with PostgreSQL 18 on the Enterprise Plus tier. If you're still weighing self-hosting against Supabase Cloud, our Supabase pricing calculator compares the two for your own usage.
This post covers everything we learned setting it up: the configuration decisions, the gotchas, and the features that make Enterprise Plus worth considering.
Why Enterprise Plus?
GCP offers two Cloud SQL editions:
| Feature | Enterprise | Enterprise Plus |
|---|---|---|
| Availability SLA | 99.95% | 99.99% |
| Max instance size | 96 vCPUs / 624 GB RAM | 128 vCPUs / 864 GB RAM |
| Data Cache | No | Yes |
| Point-in-time recovery | Yes | Yes |
| Read replicas | Yes | Yes |
| Private networking | Yes | Yes |
The feature that mattered most to us was Data Cache.
What is Data Cache?
Data Cache keeps data pages on fast local SSDs attached to the instance. Google describes it as extending the operating system's page cache from memory onto that local SSD (Data Cache docs). When your working set doesn't fit in memory, reads that would have gone to persistent storage come from the local SSD instead, reducing disk I/O and improving query latency.
It isn't a separate cache your application talks to, like Redis:
- You don't manage it
- It's automatically populated based on access patterns
- It's billed separately from the instance, per GiB of cache (pricing), and Google turns it on by default for new Enterprise Plus instances
- It works transparently with your existing queries
For read-heavy workloads (which most web applications are), this is a significant performance boost without any code changes.
Our database configuration
We configure Cloud SQL in Pulumi like this:
this.instance = new gcp.sql.DatabaseInstance(
`${resourceName}-db`,
{
name: `${resourceName}-db`,
databaseVersion: "POSTGRES_18",
region: region,
deletionProtection: deletionProtection,
settings: {
tier: tier,
edition: "ENTERPRISE_PLUS",
availabilityType: availabilityType,
// Storage
diskSize: diskSize,
diskType: "PD_SSD",
diskAutoresize: true,
diskAutoresizeLimit: 1000,
// Data Cache
dataCacheConfig: dataCacheEnabled ? { dataCacheEnabled: true } : undefined,
// Private IP
ipConfiguration: {
ipv4Enabled: false,
privateNetwork: args.network.id,
enablePrivatePathForGoogleCloudServices: true,
},
// Backups
backupConfiguration: {
enabled: true,
startTime: "03:00",
pointInTimeRecoveryEnabled: true,
transactionLogRetentionDays: 7,
backupRetentionSettings: {
retainedBackups: backupRetainedDays,
retentionUnit: "COUNT",
},
},
// Maintenance
maintenanceWindow: {
day: 7, // Sunday
hour: 4, // 4 AM UTC
updateTrack: "stable",
},
// Database flags
databaseFlags: [
{ name: "max_connections", value: maxConnections.toString() },
{ name: "cloudsql.iam_authentication", value: "on" },
],
// Query monitoring
insightsConfig: {
queryInsightsEnabled: true,
queryPlansPerMinute: 5,
queryStringLength: 1024,
recordApplicationTags: true,
recordClientAddress: true,
},
},
},
{
parent: this,
dependsOn: [args.privateVpcConnection],
},
);The sections below go through each part.
Instance tiers and sizing
Cloud SQL uses a tiered naming convention for machine types. For Enterprise Plus, the performance-optimized tiers are what you want:
db-perf-optimized-N-{vCPUs}
Common configurations:
| Tier | vCPUs | Memory | Use Case |
|---|---|---|---|
| db-perf-optimized-N-2 | 2 | 16 GB | Small dev environments |
| db-perf-optimized-N-4 | 4 | 32 GB | Dev/staging, light production |
| db-perf-optimized-N-8 | 8 | 64 GB | Production workloads |
| db-perf-optimized-N-16 | 16 | 128 GB | High-traffic applications |
| db-perf-optimized-N-32 | 32 | 256 GB | Enterprise workloads |
We use db-perf-optimized-N-4 for development (32 GB RAM is plenty for testing) and db-perf-optimized-N-8 for production.
The memory matters
Memory is still the first cache. If your working dataset fits in memory, you'll see much lower query latencies, and Data Cache has little to do. It pays off when the working set outgrows memory. Its size comes with the tier: the number of vCPUs sets the size of the local SSD, and you can't resize it separately.
Storage configuration
diskSize: diskSize,
diskType: "PD_SSD",
diskAutoresize: true,
diskAutoresizeLimit: 1000,SSD storage
Always use PD_SSD. The IOPS and latency improvements over standard persistent disk are significant for database workloads. The cost difference is minor compared to the performance gain.
Auto-resize
Enable diskAutoresize to prevent running out of space. Cloud SQL checks the free space every 30 seconds and adds storage when it falls below a threshold that depends on the disk's size: for SSD, 5 GB plus 1/25 of the provisioned size, up to 25 GB (Google's storage settings). On our 250 GB disks that means growing once less than 15 GB is free, about 94% full, by 15 GB at a time.
We set diskAutoresizeLimit: 1000 (1 TB) as a safety cap. This prevents runaway costs if something goes wrong with data growth.
Warning: Treat every increase as permanent. Cloud SQL can shrink storage, but only as a separate operation that takes the instance down while it runs, and Google says it isn't supported with Terraform. Start with a reasonable minimum and let it grow.
Availability and redundancy
availabilityType: "REGIONAL", // or "ZONAL"ZONAL (Single-zone)
- Instance runs in one zone
- Cheaper
- Downtime during zone failures
- Good for: Development, non-critical workloads
REGIONAL (Multi-zone)
- Primary instance + standby in different zones
- Automatic failover, with the instance unavailable for about sixty seconds according to Google's HA docs, which add that this can differ by environment
- Required for 99.99% SLA
- Good for: Production workloads
Sixty seconds is what to expect, not a promise. When a data center hosting europe-west2-b lost power on October 20, 2026, Cloud SQL immediately started automated failovers for all regional HA instances. Instances without Regional Persistent Disk failures completed their failover, which Google says mitigated their impact right away. Most of the rest recovered by 09:00 BST, about two hours after the power cut, and the last few by 19:00 BST (Google's incident report, revised November 4). Google says it's working to make HA instances on Regional Persistent Disk recover faster.
Failover also closes existing connections to the primary and its read replicas. Make sure your app and its connection pooler reconnect on their own, and test it with gcloud sql instances failover INSTANCE_NAME, as Google recommends, so you know what your users would see before a real outage shows you.
We use ZONAL for dev (save costs) and REGIONAL for prod (maximize availability).
Private networking
This matters for security: we never expose the database to the public internet.
ipConfiguration: {
ipv4Enabled: false,
privateNetwork: args.network.id,
enablePrivatePathForGoogleCloudServices: true,
},How it works
- VPC Peering: Cloud SQL creates a peering connection to your VPC
- Private IP: The database gets an internal IP address in your network
- No public exposure:
ipv4Enabled: falseensures no public IP is assigned
The setup requirement
Before creating a Cloud SQL instance with private IP, you need to establish the private services connection:
// Reserve an IP range for Cloud SQL
this.privateIpRange = new gcp.compute.GlobalAddress(`${resourceName}-private-ip-range`, {
purpose: "VPC_PEERING",
addressType: "INTERNAL",
prefixLength: 16,
network: this.vpc.id,
});
// Create the peering connection
this.privateVpcConnection = new gcp.servicenetworking.Connection(`${resourceName}-private-vpc-connection`, {
network: this.vpc.id,
service: "servicenetworking.googleapis.com",
reservedPeeringRanges: [this.privateIpRange.name],
});The key detail: Cloud SQL depends on this connection. In Pulumi, we express this explicitly:
{
dependsOn: [args.privateVpcConnection],
}Without this dependency, Pulumi might try to create the database before the VPC peering is ready, and you'll get cryptic networking errors.
Private path for Google services
enablePrivatePathForGoogleCloudServices: true,This lets other Google Cloud services, such as BigQuery, query the database over a private connection (Google's instance settings). Services that run in your VPC, like GKE, or connect to it, like Cloud Run with Direct VPC egress, reach the private IP without it.
Backup configuration
Backups are non-negotiable for production databases.
backupConfiguration: {
enabled: true,
startTime: "03:00", // 3 AM UTC
pointInTimeRecoveryEnabled: true,
transactionLogRetentionDays: 7,
backupRetentionSettings: {
retainedBackups: 35,
retentionUnit: "COUNT",
},
},Daily automated backups
startTime: "03:00" schedules backups at 3 AM UTC. Choose a time when your database has low activity.
Point-in-time recovery (PITR)
When enabled, Cloud SQL continuously writes transaction logs to storage. You can restore to any point within the retention window, not just to the daily backup.
transactionLogRetentionDays: 7 means you can restore to any moment in the last week. On Supabase Cloud, the same 7-day window costs about $100 a month per project. A HIPAA project there must have it on, so it's part of the Supabase HIPAA cost.
Backup retention
We keep 35 daily backups (about 5 weeks). This gives us enough history to recover from issues that aren't noticed immediately.
Tip: Test your restore process regularly. Backups are worthless if you can't restore from them.
Maintenance windows
maintenanceWindow: {
day: 7, // Sunday
hour: 4, // 4 AM UTC
updateTrack: "stable",
},GCP applies security patches and updates during maintenance windows. By specifying day and hour, you control when this happens.
We choose Sunday at 4 AM UTC, the lowest-traffic time for most business applications.
Update tracks
- stable: Updates after they've been tested in production by other users
- canary: Get updates earlier (useful for testing)
Stick with stable for production.
Database flags
databaseFlags: [
{ name: "max_connections", value: maxConnections.toString() },
{ name: "cloudsql.iam_authentication", value: "on" },
],- max_connections: Cloud SQL sets the default from the instance's memory: 600 connections from 30 GB and 800 from 60 GB, so our 32 GB and 64 GB instances would start at 600 and 800 (Cloud SQL flags). We set it to 200, below either default. Adjust based on your needs:
- Connection poolers like PgBouncer can reduce the connections you need
- Each connection uses memory, so don't set this arbitrarily high
- Monitor
pg_stat_activityto see actual usage
- IAM authentication:
cloudsql.iam_authenticationenables authentication using GCP IAM users and service accounts. This is useful for:- Service accounts connecting from Cloud Run, GKE, etc.
- Developers connecting via Cloud SQL Auth Proxy
- Reducing password management overhead
Query Insights
insightsConfig: {
queryInsightsEnabled: true,
queryPlansPerMinute: 5,
queryStringLength: 1024,
recordApplicationTags: true,
recordClientAddress: true,
},Query Insights is free and provides invaluable debugging information:
- Top queries by CPU, latency, and IO
- Query plans for slow queries
- Historical trends
We enable all options. The overhead is minimal, and the visibility is worth it.
Creating the database and user
The Cloud SQL instance is just the server. You also need a database and user:
this.database = new gcp.sql.Database(
`${resourceName}-database`,
{
name: args.databaseName,
instance: this.instance.name,
charset: "UTF8",
collation: "en_US.UTF8",
},
{ parent: this },
);
this.user = new gcp.sql.User(
`${resourceName}-db-user`,
{
name: "postgres",
instance: this.instance.name,
password: args.password,
},
{ parent: this },
);Character set and collation
UTF8 with en_US.UTF8 collation is the safe default for most applications. If you have specific locale requirements, adjust accordingly.
The postgres user
We use the built-in postgres user. On Cloud SQL it isn't a superuser: it has CREATEROLE, CREATEDB and LOGIN and belongs to cloudsqlsuperuser (Cloud SQL users). For enhanced security, you could:
- Create a separate application user with limited privileges
- Disable the postgres user after setup
- Use IAM authentication for application access
For now, password authentication with secrets management (via Infisical) works well for our use case.
Environment presets
Rather than duplicating configuration, we use presets:
export const DatabasePresets = {
dev: {
tier: "db-perf-optimized-N-4",
edition: "ENTERPRISE_PLUS",
availabilityType: "ZONAL" as const,
diskSize: 250,
dataCacheEnabled: true,
deletionProtection: false,
backupRetainedDays: 35,
},
prod: {
tier: "db-perf-optimized-N-8",
edition: "ENTERPRISE_PLUS",
availabilityType: "REGIONAL" as const,
diskSize: 250,
dataCacheEnabled: true,
deletionProtection: true,
backupRetainedDays: 35,
},
};Key differences:
| Setting | Dev | Prod | Why |
|---|---|---|---|
| Tier | N-4 (4 vCPU) | N-8 (8 vCPU) | Prod handles more load |
| Availability | ZONAL | REGIONAL | Prod needs HA |
| Deletion protection | Off | On | Prevent accidental deletion in prod |
Connecting to the database
From within GCP
Applications running in the same VPC can connect directly using the private IP:
const connectionString = pulumi.interpolate`postgresql://postgres:${password}@${database.privateIp}:5432/${dbName}`;With the Cloud SQL Auth Proxy
For development, the Cloud SQL Auth Proxy is the usual tool, but it doesn't create a network path of its own. Our instance has no public IP, so the proxy has to run on a machine with access to the VPC, and it needs --private-ip (Auth Proxy docs):
# Install the proxy
gcloud components install cloud-sql-proxy
# On a machine in the VPC (this listens on localhost:5432)
cloud-sql-proxy --private-ip --port 5432 PROJECT:REGION:INSTANCE_NAMEThen, on that machine, connect as if the database were local:
psql -h localhost -U postgres -d mydbVia VPN and a bastion
Our VPN doesn't reach the database on its own. Outline only forwards traffic to public addresses: its server refuses connections to private ranges such as 10.0.0.0/8, and there's no setting to allow them. So we run a bastion, a small VM in the VPC with a public IP that only accepts connections from the Outline server. It opens a different port for each service and forwards it to that service's private IP. Each one also has a DNS name pointing at the bastion, such as db.<domain> for the main database and db-us.<domain> for the US one, so nobody has to remember IPs or ports. On the VPN, a developer connects with:
psql "host=db.<domain> port=PORT user=postgres dbname=mydb sslmode=require"That works for any tool that speaks Postgres, including ones that don't support the Cloud SQL Auth Proxy.
Common gotchas
1. VPC peering takes time
The private VPC connection can take 5-10 minutes to establish. If your pulumi up seems stuck on the database creation, this is likely why.
2. Connection limits with serverless
Cloud Run and similar services can create many connections quickly. Use a connection pooler (PgBouncer, Prisma's built-in pooling) or Cloud SQL's built-in connection pooling.
3. Disk is hard to shrink
An increase stays unless you shrink the storage by hand, which takes the instance down while it runs. Start smaller and let auto-resize handle growth.
4. Maintenance can cause brief downtime
Even with REGIONAL availability, maintenance updates can cause brief (seconds) connection interruptions. Design your application to handle database reconnection gracefully.
A major version upgrade is a longer outage. Our test upgrade from PostgreSQL 14 to 18 used two 2 vCPU instances on the Enterprise edition, and clients couldn't connect to either for about nine minutes.
5. Backups aren't free
Backup storage costs money. 35 daily backups of a large database adds up. Monitor your storage costs.
Monitoring and alerts
Beyond Query Insights, set up alerts for:
- CPU utilization > 80% sustained
- Memory utilization > 90%
- Disk utilization > 80%
- Connection count approaching max_connections
- Replication lag (if using read replicas)
You can set all of these up in GCP Cloud Monitoring.
Next steps
Two posts take this setup further:
- Multi-region PostgreSQL on Google Cloud: why we dropped our read-replica plan, and how three regions that all take writes stay in sync with pglogical.
- PostgreSQL 14 end of life on Cloud SQL: what extended support costs, and what broke in our timed upgrade to 18.
Want PostgreSQL on Google Cloud set up like this? We set up and run self-hosted Supabase on Cloud SQL for teams that need control over their data.

