Alternative Setup Vercel + Supabase
I’m currently building a project with Next.js where I provide multiple API endpoints as well as embeddable widgets that can be integrated via iFrame.
At the moment, my stack consists of Vercel for hosting and Supabase for managing API key validation and rate limiting.
Current Setup:
- Next.js API routes serve both JSON endpoints and dynamic widgets.
- Widgets are highly dynamic and can trigger a large number of requests.
- Supabase stores API keys and tracks usage for rate limiting.
Challenges:
Because the widgets are dynamic, many requests cannot be cached effectively. This raises a few concerns:
- Every request may require checking the API key in Supabase.
- Rate limit counters need to be updated frequently.
- This could lead to significant database load and potentially high costs.
I’m considering moving away from Vercel, and possibly reducing the amount of real-time reads/writes to Supabase.
For example:
- API keys could be cached in memory or in Redis.
- Rate limit counters could be accumulated temporarily and written back to Supabase in batches.
- More flexible rate limiting could be implemented without hitting the database on every request.
Main Concern: Cost Predictability
I’m hesitant to launch this setup on Vercel + Supabase because I’ve read many stories about unexpected costs after moving from the free tier to paid plans.
The free tiers are generous, which makes it difficult to estimate actual production costs. Since I need to define pricing for my own customers, predictable infrastructure costs are very important.
What I’m Looking For:
I’d love to hear recommendations for a more cost-effective and predictable setup for this use case.
Requirements:
- Host Next.js API endpoints and dynamic iFrame widgets
- API key validation
- Rate limiting
- Preferably EU/Germany hosting options
- Clear and predictable pricing
- Scalable for high request volumes
Alternatives I’m Considering
(These are technologies and providers I’ve seen recommended here on Reddit, but I don’t yet fully understand the differences between them, and some of them may be too complex for me to start with.)
- VPS providers like Hetzner or Netcup
- Redis for caching API keys and rate limit counters
- PostgreSQL for persistent storage
- Self-hosted Next.js instead of Vercel
If anyone has experience with a similar architecture, I’d really appreciate your advice on hosting, caching, and rate limiting strategies.