Khoa Nguyen

All rights reserved © yunkhngn · v1.7.13

Journal
Edit

Engineering · 2026-11-27 · 4 min read · 10 views

Optimizing a blog system by leveraging free tier infrastructure packages

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.

Optimizing a blog system by leveraging free tier infrastructure packages

On this page

  1. Overview of the problem
  2. Issue 1: Vercel ISR and the Write Units nightmare
  3. Cause
  4. Resolution
  5. Issue 2: BullMQ and Upstash Redis exhausting the 500k commands quota
  6. Cause
  7. Resolution
  8. Optimization checklist for Free/Hobby Tier
  9. Conclusion
On this page
  1. Overview of the problem
  2. Issue 1: Vercel ISR and the Write Units nightmare
  3. Cause
  4. Resolution
  5. Issue 2: BullMQ and Upstash Redis exhausting the 500k commands quota
  6. Cause
  7. Resolution
  8. Optimization checklist for Free/Hobby Tier
  9. Conclusion

Overview of the problem

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.

Issue 1: Vercel ISR and the Write Units nightmare

Cause

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.

Resolution

  • 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.

Issue 2: BullMQ and Upstash Redis exhausting the 500k commands quota

Cause

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.

Flowchart
Loading diagram…

Resolution

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,
  },
});

Optimization checklist for Free/Hobby Tier

Derived from hands-on experience, here is a quick checklist to help developers maintain a stable system without spending money:

  1. Recheck all usages of cookies() and headers() in Next.js to avoid accidentally forcing static pages to become dynamic.

  2. Avoid embedding heavy base64 strings into state or cache; push large files to object storage like S3.

  3. Reconfigure drainDelay for BullMQ workers to save Redis commands when idle.

  4. Set up alerts close to the quota limits of Vercel, Render, and Upstash to handle issues early before the system crashes.

Conclusion

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.

Comments

No comments yet. Start the conversation.

Keep exploring

From the journal

2026-12-04

Building Reliable Background Jobs in Node.js with BullMQ and Redis

A practical guide to implementing robust background processing in Node.js using BullMQ and Redis, covering retries, concurrency, and failure handling.

2026-12-04

NestJS vs Spring Boot: Choosing the Right Backend Framework

An in-depth technical comparison of NestJS and Spring Boot covering architecture, dependency injection, performance, and an objective decision framework.

2026-11-16

Building Distributed Systems: From Monolith to Microservices

An analysis of the challenges and lessons learned when migrating system architecture from a Monolith to Microservices within a distributed environment.

Related work

2025

Yunkhngn Microservice Platform

A sophisticated microservice ecosystem powering a personal portfolio and interactive digital experiences, utilizing AI-driven image processing and a robust, containerized architecture.

2025

yunkhngn-blog

A personal blog project built with modern web technologies, featuring responsive design, Markdown-based posts, and syntax highlighting for code.