Launch offer: the first 1,000 users get Settl free for a year* Claim your spot
settlbuilding in public

Benchmark before believing: my test template + revert criteria

I swapped pg for the vendor's WebSocket-based "serverless driver", the one every guide recommends. My measured cold trace: 731ms vs 502ms. Slower. And Sentry showed zero database spans, because its Postgres tracing only patches the classic TCP pg path. WebSocket-over-fetch is invisible to it. Slower AND blind. Reverted same day.

Why the recommended thing lost

The serverless driver's win is skipping TCP+TLS handshakes across regions. But I'd already moved my DB in-region, where a fresh handshake costs ~30ms. The driver's overhead exceeded its savings on my workload. Benchmarks in blog posts were run on someone else's architecture.

The benchmark template

  1. Define the metric before switching. Mine: a cold-start trace of my heaviest real endpoint, plus compute-time and span visibility. Pick a REAL endpoint, not SELECT 1.
  2. Hold everything else constant. Same region, same data volume, same deploy target. Branch the driver choice on an env var so both paths exist in one commit:
const useNewDriver = process.env.DB_DRIVER === 'serverless';
export const db = useNewDriver ? makeServerlessPool(url) : makePgPool(url);
  1. Measure side-by-side in production conditions. Deploy both, capture 10+ cold and 10+ warm traces each. My numbers: pg.Pool 502ms total / 156ms compute / ~22 DB spans visible; serverless driver 731ms / 271ms compute / 0 spans.
  2. Count observability as a feature you can lose. A driver that hides your queries from tracing has negative value during your next incident. Weight it like a latency regression.
  3. Write the revert criteria BEFORE the experiment. Mine: revert if (a) not meaningfully faster on cold start, or (b) any loss of DB visibility. Both tripped. Decision took zero deliberation because it was pre-made.
  4. Revert fast, document why. Same-day revert, and I left the analysis as a comment in the db package so the next reader (or agent) doesn't "re-discover" the recommended driver.
  5. Re-test when conditions change. The driver lost under my conditions: in-region, with tracing needs. If I ever run edge functions far from the DB, the math flips; the env-var branch makes retesting cheap.

Steal this for your app

Run this on your codebase

Paste this into Claude Code in your repo:

Audit this repo for driver and SDK swaps that were never benchmarked.
Identify the database driver in use (pg, @neondatabase/serverless, postgres.js) and whether it connects over TCP or WebSocket/fetch.
Check whether our tracing or APM setup actually instruments that driver; flag any query path that produces zero spans.
Compare DB region to compute region and note whether a handshake-skipping serverless driver even has a win here.
Look for an env-var branch that lets us run old and new driver side by side in one commit; propose one if missing.
List recent dependency swaps in the lockfile that have no recorded benchmark or revert criteria.
Report findings as a checklist before changing anything.

Get the next one in your inbox