PostgresQL benchmark with serverless functions 𐄷

Technologies used ⚙️

Next.js   •   Prisma   •   Digital ocean   •   K6

Benchmark architecture

Prisma accepts environment variable as database connection string - this Next.js app is ran on Vercel on two instances. Each instance accepts different db connection string - in one case it is a simple managed DB from Digital Ocean, in other case it's a PG bouncer powered managed DB on Digital Ocean.

k6 directory implements load tests to be run against these two branches.

Results

In case of plain DB serverless functions quickly exhaust connection limits of the DB which results in failed requests thus in failed threshold of K6 testing.

In case of PG bouncer powered db everything works as expected with little performance downsides.

Alternatives to the approach

Using serverless oriented DB with serverless functions - Dynamo, Aurora

Using Prisma Data Proxy