Skip to content

Use Aurora DSQL instead of Aurora Serverless v2 #91

@tmokmss

Description

@tmokmss

This project currently uses Amazon Aurora PostgreSQL Serverless v2 + Prisma ORM. I propose migrating to Amazon Aurora DSQL.

Benefits of Migration

Pain Points of Aurora Serverless v2

  • Cold start: When Scale to Zero is enabled, resuming takes 15–30 seconds. This is unacceptable for user-facing applications
  • Scale to Zero is hard to benefit from: Although Scale to Zero exists, configurations where cron jobs access the DB every 10 minutes keep the cluster warm at all times, completely negating cost savings
  • VPC required: Requires NAT Gateway/Instance, which adds architectural complexity and cost
  • Connection management: RDS Proxy is needed for handling many concurrent connections from Lambda, but it doesn't fully solve the problem

Advantages of Aurora DSQL

  • Truly serverless: No infrastructure management, automatic scaling, no cold starts when idle
  • No VPC required: Connects via public endpoint. Eliminates the need for NAT Gateway/Instance, greatly simplifying the architecture
  • IAM authentication: No database password management needed

Migration Blockers

1. ORM Compatibility Issues

This project uses Prisma ORM, which has known issues when used with DSQL.

  • Prisma: db push fails under certain conditions → prisma/prisma#26643
    • AWS has released official DSQL support for Prisma (announcement), including the aurora-dsql-prisma CLI tool that can automatically handle DDL transaction constraints, FK constraint removal, etc.
    • For db migration, generating migrations against a local PostgreSQL and applying them to DSQL via the CLI tool can work around the db push issues
  • Drizzle ORM: DSQL support feature request is in progress → drizzle-team/drizzle-orm#5248
    • A member of the DSQL service team is actively working on a patch, but it is still in early stages

2. Unsupported PostgreSQL Features

DSQL is PostgreSQL-compatible, but some features are not supported. If the current codebase uses any of these features, application-side changes will be required.

Unsupported PostgreSQL features in Aurora DSQL

3. Different Transaction Model

  • DSQL uses Optimistic Concurrency Control (OCC)
  • Transactions may be aborted on write conflicts, so retry logic needs to be implemented
  • Isolation level is fixed at Repeatable Read

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions