October 21, 2024
4 mins

Managing Scheduled Jobs in Bubble.io

Managing Scheduled Jobs in Bubble.io: Why Long-Running Schedules Might Be a Bad Idea

When designing scheduled workflows in Bubble.io, things may seem straightforward at first. Scheduling a workflow to trigger at a specific date and time is easy, and most would assume, “If the actions and timing are clear, why not just schedule it?” However, as you start to scale and add complexity, managing these scheduled jobs can become a nightmare.

Let me share a real-world example: currently, I’m refining a subscription reminder service for a client’s Bubble app. Here’s the basic setup: a subscriber signs up on January 14, 2024, and we schedule a reminder email for January 14, 2025, to notify them that their subscription is expiring. Sounds simple, right? This was exactly what the client requested at the time.

However, this design leads to several operational issues:

1. Handling Subscription Changes

Over time, subscriptions evolve. Users may cancel, extend, transfer their subscription to another account, or update their email address. All of these changes complicate what was initially a simple scheduled job. How do you ensure the reminder is accurate when there’s so much change?

2. Dealing with Workflow Crashes

In Bubble, scheduled jobs can sometimes go off-track. For instance, you may have a recursive workflow that spirals out of control, forcing you to stop all scheduled jobs immediately. In a busy Bubble app, this could mean manually sorting through thousands of jobs—an operational disaster in a high-pressure situation.

3. Reconciling Jobs with a Job Table

One solution is to create a “job table” that stores metadata about your scheduled workflows. This gives you visibility and some control, but introduces a new problem: reconciling your job table with the Bubble scheduler. Is everything in the table perfectly aligned with what’s actually scheduled in Bubble? Any drift between the two could become a serious issue.

4. Time Zone Discrepancies

If your scheduled workflows involve time-sensitive actions (like sending emails at 7am in the user’s local time), things get even trickier. Managing time zones in Bubble’s scheduler isn’t as seamless as you’d like, and ensuring that each workflow runs in the correct time zone is another layer of complexity.

5. Adapting to Changing Business Rules

What if your business rules change? For example, let’s say in October you decide reminders should be sent two weeks before the subscription ends, instead of one. All your previously scheduled jobs are now incorrect, creating a mismatch between the original scheduling logic and your new business requirements.

Potential Workarounds

There are some workarounds, such as adding bogus parameters to your workflows to give scheduled jobs more meaningful descriptions. You can even export the scheduler's data into a spreadsheet and compare it against your job table and accounting system. But, as you can imagine, this quickly becomes messy and inefficient.

One technique to make your workflows easier to manage is to use a batch type job - eg weekly - say Sunday night to schedule the reminders for the next 7 days. This can potentially give you the flexibility and granularity that you might need.

Key Takeaways for Managing Scheduled Jobs in Bubble

  1. Long-Running Schedules are Risky
    Avoid using Bubble’s scheduler for long-term tasks (e.g., reminders a year from now). Things change, and Bubble’s scheduler isn’t built to handle evolving workflows efficiently.
  2. Batch Jobs Can Be a Good Fit
    Scheduled workflows still have their place for end-of-period jobs, like weekly or monthly batch processing.
  3. Idempotent Jobs Are Ideal
    Ensure your jobs are idempotent—meaning they can be run multiple times without unintended consequences. However, be aware that Work Unit (WU) costs come into play here.
  4. Reconciliation is the Hard Part
    Managing scheduled jobs and keeping them in sync with other systems is the hardest challenge. For this reason, the Bubble scheduler should only be used to trigger tasks in the future, not for enforcing core business rules.

Conclusion

Designing and managing scheduled tasks in Bubble.io can be more complex than it appears. Long-running schedules, time zone issues, and the reconciliation of jobs across systems make Bubble’s scheduler less ideal for time-sensitive or evolving business needs. Instead, consider using it for simpler, short-term workflows and look for alternative methods to handle long-term, recurring jobs.

Hopefully, this helps clarify some of the nuances involved in scheduling workflows within Bubble.io, and helps you avoid some common pitfalls.