advanced

Managed databases

Choose managed database services for backups, patching, replicas, failover, scaling, connection limits, and operational ownership.

Managed databases (RDS, Cloud SQL, Azure SQL, PlanetScale-style offerings) outsource patching, backups, failover, and replication while the application team still owns schema, queries, indexes, connection pooling, and migration strategy. For Node.js use `pg`, Prisma, or Drizzle with pool limits that match instance `max_connections`.

| Decision | Question | |----------|----------| | Engine | Postgres vs MySQL vs serverless SQL | | HA | Multi-AZ, read replicas, RPO/RTO | | Scaling | Vertical tier vs read replicas vs sharding | | Access | Private VPC, IAM auth, rotation |

Run migrations in CI with reviewed SQL; test restore from backup quarterly. Use connection poolers (PgBouncer, RDS Proxy) when many short-lived serverless invocations hit the DB.

On interviews: failover behavior, read replica lag, connection storms from Lambda, backup retention, and when managed NoSQL fits better than SQL.

Common pitfalls: no indexes on production-scale tables; ORM N+1 under load; storing files in BLOB columns; running migrations without lock timeout strategy.

The trade-off is reduced ops toil versus vendor lock-in, tier cost, and less low-level tuning control than self-hosted Postgres.

Checklist:

  • Size connections for poolers and serverless bursts.
  • Automate backups and test restore.
  • Index and explain slow queries in staging.
  • Separate migration role from runtime app role.