The Viral Problem
Your app is on the front page of Hacker News. 5,000 people visit in an hour. Your database is timing out. Your server is returning 500 errors. Your free-tier Supabase database has hit its connection limit.
This is not hypothetical. It happens to almost every vibe-coded app that gets real traction.
This chapter is about the practical things that break under load, and how to fix them before they happen.
---
What Breaks First (In Order)
1. Database Connections (Breaks at ~10 concurrent users on free tier)
Supabase's free tier allows 60 simultaneous database connections. A single Next.js Vercel deployment can easily exhaust this during a traffic spike because each serverless function invocation opens its own connection.
Fix: Add PgBouncer connection pooling
Supabase provides a connection pooler (PgBouncer) by default. In your Supabase client configuration, use the pooler connection string instead of the direct connection:
Find your pooler URL in Supabase Dashboard → Project Settings → Database → Connection Pooling.
2. AI API Rate Limits (Breaks at ~50 concurrent requests)
OpenAI, Anthropic, and Google all enforce rate limits — typically measured in requests per minute (RPM) and tokens per minute (TPM). During a viral spike, your AI API calls will start returning 429 (Too Many Requests) errors.
Fix: Add a queue and retry logic
Get advanced blueprint resources
Enter your email to receive technical blueprints, checklists, and visual configurations accompanying this chapter.
No spam. Unsubscribe any time.
For sustained high traffic, implement a proper job queue (Upstash QStash, BullMQ, or even Supabase Edge Functions as workers).
3. Vercel Function Timeouts (Breaks AI features at ~10 seconds)
Vercel's free tier serverless functions timeout after 10 seconds. AI generation (especially video, image, or complex text) can take 30-120 seconds.
Fix: Use background jobs instead of synchronous responses
4. Unindexed Database Queries (Breaks at ~1000 records)
Queries that work instantly with 100 records can take seconds with 10,000 records — and minutes with 1,000,000. This is almost always an indexing problem.
Fix: Add indexes to every column you query on
5. Missing Caching (The Expensive Re-Computation Problem)
If your most popular feature makes an expensive AI call on every request, you will burn through your AI API budget instantly during a spike. Many requests are for identical or near-identical inputs.
Fix: Cache AI responses
---
The Pre-Launch Scaling Checklist
Before launching anything with significant marketing effort:
- [ ] Database using pooled connection string
- [ ] All query columns are indexed
- [ ] AI calls have exponential backoff retry logic
- [ ] Long-running operations use job queue pattern
- [ ] Identical inputs are cached
- [ ] Rate limiting on your own API (prevent abuse)
- [ ] Uptime monitoring is configured (Better Uptime, UptimeRobot — both have free tiers)
- [ ] Error alerting is configured (Sentry free tier)