Senior Backend/Infra Engineer — stabilize & re-architect a Supabase + Next.js + Cloudflare
Buget: $15.0 - $45.0
HOURLY / FULL_TIME
⭐ 4.92 (43)
United States
cloudflare, javascript, node.js, python
We run an internal operations platform for a multi-shop TikTok Shop business: order ingestion, inventory/listing sync, reconciliation, live-auction tooling, reporting. Stack: Next.js 16 on Vercel, Supabase (Postgres + PostgREST + pg_cron + Edge Functions), some Cloudflare Workers, n8n. It is built and maintained by a very small, non-engineer team, and it has outgrown that.
**The problem (we want someone who has solved exactly this)**
The website repeatedly goes fully down (Vercel `MIDDLEWARE_INVOCATION_TIMEOUT` / sitewide 504) because the single shared Postgres connection pool gets exhausted. Everything — the web app, ~25 pg_cron jobs, and many long-running Edge Functions — competes for the same PostgREST/`authenticator` pool. A few heavy operations (e.g., a scheduled aggregation function that holds a connection ~35 seconds, twice an hour) plus normal load periodically tip the pool over; once it tips, trivial queries hang for minutes and the whole site is down until a manual compute restart. We have stopped the bleeding (disabled the heavy schedulers, made the auth middleware fail-open) and have a documented analysis + a proposed direction, but we need a real engineer to design and implement the durable fix and then run it.
**What you'll do**
1. **Stabilize:** confirm and harden the connection-bulkhead approach (isolate background/cron work from the app's connection budget so a bad job can never take the site down).
2. **Fix the heavy queries:** profile and rewrite/optimize or reschedule the specific offenders (we have `pg_stat_statements`/cron run-history data pinpointing them — e.g., a ~35s `refresh_live_floor_snap()` aggregation).
3. **Re-architect work execution off the transactional DB:** move crons + ingestion + (eventually) live-AI processing into a proper queue + bounded-worker model (Cloudflare Workers/Queues/Hyperdrive, or a managed durable-execution platform like Inngest/Trigger.dev — your recommendation, with honest tradeoffs). Postgres stays the system of record. We have a half-built Cloudflare pilot you'd finish/replace; it currently fails to connect via Hyperdrive ("network connection lost") and we need someone who actually knows this terrain.
4. **Operate & document:** monitoring/alerting on pool pressure before it 504s, runbooks, and a sane rollout so a 2-person team can run it without firefighting.
**Must-have**
- Deep PostgreSQL performance + connection management: pooling (PgBouncer/Supavisor/Hyperdrive), `statement_timeout`, `pg_stat_statements`, query optimization, reading `pg_stat_activity`.
- Real production experience with serverless/edge → Postgres connection-exhaustion problems and how to actually fix them (not theory).
- Supabase (PostgREST, pg_cron, Edge Functions) and/or equivalent (RDS+Lambda etc.).
- A queue/worker or durable-execution architecture you've shipped (Cloudflare Queues/Workers, Inngest, Trigger.dev, Temporal, SQS+workers, etc.).
- Next.js / Vercel familiarity (middleware, server actions).
- Clear written communication; comfortable working with a non-engineer owner and documenting decisions.
**Nice-to-have**
- Cloudflare Hyperdrive + Supabase specifically.
- TikTok Shop Partner API experience.
- n8n.
**Screening questions (please answer in your proposal — applications without these are skipped):**
1. A serverless/edge app shares one Postgres pool with background cron jobs; under load the whole app 504s while Postgres itself looks healthy. Walk me through how you diagnose it and the top 2-3 structural fixes you'd apply.
2. Briefly describe a time you moved heavy/scheduled work off a transactional database. What did you use, and what was the connection model?
3. Cloudflare Hyperdrive to a Supabase Postgres returns "network connection lost." What are the first things you'd check?
**To apply:** answer the 3 questions, link 1-2 relevant past projects, and note your timezone and earliest availability for an urgent stabilization session.
Deschide pe Upwork