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

Show all 13 facts

Related talks