Goodbye Scattered Cron Jobs: Heartbeat's Centralized Task Scheduler

2025-08-01
Goodbye Scattered Cron Jobs: Heartbeat's Centralized Task Scheduler

Heartbeat previously used multiple Cron Jobs to manage scheduled tasks, resulting in high maintenance costs and frequent errors. This article describes how they built a centralized, database-driven task scheduler using a single `ScheduledTasks` database table and a single Cron Job to manage all scheduled tasks. Leveraging AWS SQS for asynchronous processing, the system ensures reliable task execution, retry mechanisms, and robust monitoring. This approach addresses issues like task management chaos, difficult error handling, and simplifies the addition of new scheduled tasks.

Read more
Development task scheduling

Type-Driven Development: How Types Simplify Complex Programming

2024-12-19
Type-Driven Development: How Types Simplify Complex Programming

This article explores the concept of "Type-Driven Development," where the author, drawing from experience with the large-scale Heartbeat Typescript project (300k+ lines), demonstrates how Typescript's type system simplifies complex programming problems. The core idea is that by leveraging the type system effectively, allowing types to flow freely across all application layers, starting new features with type definitions, making illegal states unrepresentable, parsing instead of validating data, and maintaining code honesty and specificity, bugs are drastically reduced and development efficiency is improved. The author also shares techniques for using pure functions as type bridges and the type system as an introspection tool, while acknowledging the occasional need to bypass type system constraints.

Read more