WhoBuilt

AWS DSQL (Postgres) with Next.js

Dec 13, 2024· 14 min· 14K views·Watch on YouTube

Leerob, a software engineer at Vercel, demonstrates AWS DSQL with a Next.js movie-voting app and explains how it connects to PostgreSQL; no other participants are identified.

What DSQL offers

Leerob describes DSQL as an early-preview, serverless distributed database compatible with much of PostgreSQL. He outlines active-active replication across three Availability Zones in one region or multiple regions, with strong consistency. The demo uses US East and US West, the only regions he says were available in the preview.

Connecting Next.js to DSQL

Leerob creates a DSQL database in the AWS console and connects with a short-lived authentication token that expires after 15 minutes. In the app, the DSQL Signer generates a token for a Node.js connection pool, which Drizzle uses for queries. Vercel OpenID Connect lets the app assume an AWS IAM role without storing long-lived access keys in project environment variables.

Building the movie-voting app

The app stores movies, sessions, and votes, and uses a cookie to keep track of whether a visitor has voted. Leerob notes that the preview did not support extensions or adding indexes after database creation, which made searching 5,000 movies harder. The Next.js app fetches data in server components and uses React 19’s useOptimistic to update vote counts while the server action writes to the database.

Rendering and observing the app

The page uses a Suspense boundary to separate static content from dynamic movie results, with experimental Next.js partial pre-rendering flags enabled in the demo. After a vote, revalidatePath refreshes the server-rendered data. Leerob also shows Vercel function observability for latency, errors, external calls, and concurrency, which he says can reduce compute costs by up to 50 or 60% for some workloads.

Early preview tradeoffs

Leerob says DSQL looks promising but is too early to assess fully: some PostgreSQL features were missing, and pricing had not been announced. He plans to keep watching as the product develops.

Takeaways

  • Place compute near replicated database regions to reduce network distance.
  • Use short-lived DSQL authentication tokens and OIDC-based IAM roles instead of long-lived access keys.
  • Check preview limits on indexes and extensions before designing search-heavy workloads.
  • Use optimistic UI updates to make database-backed interactions feel immediate.
  • Track function latency and concurrency to identify opportunities to reduce compute costs.

Mentioned in this talk

Search inside this talk

What was claimed 13

  • feature
    Amazon Aurora DSQL: Distributed, serverless, PostgreSQL-compatible SQL database
    “AWS DSQL, a distributed, serverless PostgreSQL database”
    YouTube
    Unverified1 source· Talk
  • metric
    Amazon Aurora DSQL: 99.99% availability in a single region and 99.999% in multiple regions
    “It has 99.99% availability in a single region and 99.999% in multiple regions”
    YouTube
    Unverified1 source· Talk
  • feature
    Amazon Aurora DSQL: Active-active distributed architecture with strong consistency across regions
    “It has an active-active distributed architecture.”
    YouTube
    Unverified1 source· Talk
  • feature
    Amazon Aurora DSQL: Single-region clusters span three Availability Zones
    “active across three Availability Zones”
    YouTube
    Unverified1 source· Talk
  • uses
    “Vercel is built on top of the AWS network”
    YouTube
    Unverified1 source· Talk
  • uses
    “This is using standard Node.js on Vercel Functions.”
    YouTube
    Unverified1 source· Talk
  • integrates with
    Drizzle ORM integrates with Postgres
    “I'm passing that connection along to my Drizzle ORM”
    YouTube
    Unverified1 source· Talk
  • uses
    “thanks to Vercel's OpenID Connect federation”
    YouTube
    Unverified1 source· Talk
  • integrates with
    Vercel integrates with Amazon
    “Vercel can securely connect to AWS ... through OIDC”
    YouTube
    Unverified1 source· Talk
  • feature
    Next.js: Partial pre-rendering with static shell and dynamic content inside a Suspense boundary is experimental
    “This is called partial pre-rendering. It's not stable yet”
    YouTube
    Unverified1 source· Talk
  • feature
    React: React 19 useOptimistic hook enables immediate optimistic UI updates
    “using the useOptimistic hook from React 19”
    YouTube
    Unverified1 source· Talk
  • feature
    Vercel Observability: Shows function invocations, errors, latency, and external API activity
    “see the invocations ... errors, the latency, or the different external APIs”
    YouTube
    Unverified1 source· Talk
  • feature
    Vercel Functions: Function concurrency can reduce compute costs by up to 50–60% when much function time is spent on database I/O
    “I can save up to 50 or 60% of my compute costs”
    YouTube
    Unverified1 source· Talk

Related talks