Engineering · 2026-11-27 · 4 min read · 10 views
An article sharing practical experience in operating a system on free infrastructure tiers, analyzing the causes of resource threshold breaches, and effectively optimizing Vercel ISR and BullMQ.
Running a personal system on free or hobby tiers offers significant cost savings, but it also pushes engineers into strict resource limitations. The technology stack includes Next.js deployed on Vercel Hobby, a NestJS backend on Render Hobby, a MongoDB Atlas M0 database, and Upstash Redis combined with BullMQ for background tasks.
Everything ran smoothly until the system started growing slightly and hitting the quotas of the free tier. This article will dive into the causes and solutions for each specific bottleneck.
The current Next.js system uses Incremental Static Regeneration (ISR) combined with SSR. However, misusing the cookies() function in seemingly public pages turned requests into dynamic renders, forcing Vercel to continuously recalculate.
Additionally, the habit of releasing code multiple times a day along with caching bloated objects due to directly embedding base64 data pushed Write Units to peak at about 32,000 requests per day, exceeding the allowance of Vercel Hobby.
Move public routes entirely to Static or standard ISR instead of relying on cookies() at the render layer.
Use a CSS auth toggle pattern: Render the static interface on the server, then use client-side fetch combined with a token stored in localStorage to show or hide components dedicated to logged-in users.
Separate heavy files like .gp and .pdf format documents from the main payload, store them directly on AWS S3, and return only the file path along with a slim projection optimization from MongoDB.
BullMQ defaults to continuous polling mechanisms in Redis to check for new jobs. With the default configuration, workers maintain connections and continuously send commands even in an idle state.
As a result, the free limit of 500,000 commands on Upstash Redis was burned through in a short time, causing a series of background processing pipelines to grind to a halt.
Optimize BullMQ connection configurations by fine-tuning polling time parameters:
Increase drainDelay and stalledInterval to reduce the frequency of workers pinging Redis when the queue is empty.
Apply an exponential backoff strategy for retry jobs to avoid flooding with failed request bursts.
Build a temporary in-memory fallback mechanism so the system does not crash completely when Redis hits its threshold limit.
const queue = new Queue('pet-tasks', {
connection: redisConnection,
defaultJobOptions: {
attempts: 3,
backoff: {
type: 'exponential',
delay: 5000,
},
},
settings: {
drainDelay: 30,
stalledInterval: 60000,
},
});Derived from hands-on experience, here is a quick checklist to help developers maintain a stable system without spending money:
Recheck all usages of cookies() and headers() in Next.js to avoid accidentally forcing static pages to become dynamic.
Avoid embedding heavy base64 strings into state or cache; push large files to object storage like S3.
Reconfigure drainDelay for BullMQ workers to save Redis commands when idle.
Set up alerts close to the quota limits of Vercel, Render, and Upstash to handle issues early before the system crashes.
Running a system on free/hobby tiers requires great care in architecture design and resource management. By refining the Next.js caching strategy and optimizing the BullMQ polling lifecycle, the cat-raising management system is running smoothly again.
No comments yet. Start the conversation.
Keep exploring