How to Run CRON Jobs in Postgres Without Extra Infrastructure

https://news.ycombinator.com/rss Hits: 11
Summary

I had the pleasure to spend nearly 3 years working on live video infrastructure at TV2 Norway. As you know, when it comes to infrastructure, time IS money. Everything needs to be just-in-time, especially when it comes to provisioning costly components like encoders. For example, if there's a major live sports match scheduled, you want to ensure the streaming infrastructure is set up just minutes before kickoff, and torn down shortly after the final whistle blows.The fact is, scheduling is synonymous with infrastructure complexity. But sometimes you're just working on your trusty little Node app, and all you really need is something simple — like sending a daily reminder to users about today's coding challenge. That's exactly the kind of lightweight scheduling we'll dive into in this article.Scheduling Jobs with Wasp and PgBoss​What is PgBoss?​PgBoss is a job queue built on PostgreSQL. It leverages the database's reliability, transactional safety, and scalability to manage background jobs efficiently. Unlike Redis-based queues, PgBoss doesn't require additional infrastructure — just Postgres, which is a great fit if you're already using it as your database.Key features:Transactional safety – jobs are stored in Postgres, ensuring they survive crashes.Retries & timeouts – failed jobs can be automatically retried.Scheduling – supports both delayed and recurring (CRON) jobs.No extra infrastructure - only Postgres needed.Why Wasp Makes It Even Better​Wasp is a full-stack framework for React & Node.js that simplifies web app development by handling boilerplate for you. When combined with PgBoss, Wasp provides:Declarative job definitions – define jobs directly in your Wasp config.Everything just works – no need to manually set up workers or queues.Type safety – jobs are type-checked, reducing runtime errors.NOTE: Since PgBoss runs in the same process as your Wasp app, CPU-heavy jobs can impact API responsiveness. For high-load scenarios, consider offloading to a dedicated w...

First seen: 2025-05-30 20:24

Last seen: 2025-05-31 06:26