StackpineEmail us

Pineflow · First request takes 8 seconds (cold start)

← All fixes
Ship

First request takes 8 seconds (cold start)

For Vercel: move heavy initialization out of the handler into module scope so it caches across warm invocations. For Supabase/Postgres: use a connection pooler (PgBouncer), direct connections cold-start slow. For function size: trim deps, the larger the function the slower the cold start.

Prompt to paste
Prompt
My first request is slow because of a cold start. Stack: [Vercel functions / Supabase Postgres]. Help me move heavy initialization to module scope so it caches across warm invocations, add a connection pooler for the database, and trim function size. Show me the specific code to move.