Skip to content

decision: Celery vs APScheduler+PG job store for distributed scheduling #949

Closed

Description

@vybe

✅ RESOLVED 2026-06-05 — APScheduler on a PostgreSQL job store. Celery/Celery Beat rejected. See the decision comment below and docs/planning/TARGET_ARCHITECTURE.md §Scheduling + Key Open Questions #4 (now marked Resolved). Job-store wiring folds into the PostgreSQL migration (#300). Closed as completed.


Summary

Decide whether the target-architecture scheduling layer is Celery Beat + workers (full distributed task queue) or APScheduler backed by a PostgreSQL job store (persistence without the full Celery stack).

Context

docs/planning/TARGET_ARCHITECTURE.md §"Scheduling" originally named Celery Beat as the target. After the 2026-06-05 coordination revision (push actor-model → pull / work-stealing, Epic #1045 / #1081), task execution moved onto the agents' own worker pools — leaving the scheduler with only "enqueue a queued row on a cron tick." The doc now commits to APScheduler on a PostgreSQL job store in both §Scheduling and Key Open Questions #4.

Decision (resolved)

APScheduler + PostgreSQL job store. Celery/Celery Beat rejected. Full reasoning in the decision comment. Redundancy comes from a Redis-lock leader election over a second APScheduler instance — no broker / worker processes / result backend / routing config. PgBouncer (a downstream consequence of Celery prefork workers) is avoided; PostgreSQL is the only non-negotiable new service.

Follow-up

Historical notes (pre-resolution)

🤖 Generated with Claude Code

Activity

  1. added
    priority-p3
    type-docs
    on May 26, 2026
  2. Keesan12 commented on May 26, 2026

    @Keesan12

    This looks like a coordination or scheduling contract issue. I’d make the envelope or schedule semantics visible in one place before layering on more behavior. I’d make the schedule semantics visible in one place and add a boundary test for the drift case. That keeps the fix reviewable and avoids trading one hidden failure for another. If this is useful, I can help turn it into a compact repro checklist or PR shape.

  3. added
    theme-infrastructure
    on Jun 3, 2026
  4. vybe commented on Jun 5, 2026

    @vybe
    ContributorAuthor

    Under pull (#1081) the scheduler becomes "just a producer that enqueues a queued row" and never dispatches to or blocks on an agent — which weakens the distributed-redundancy case for Celery. Decision stays p3 and orthogonal to the coordination model, which only requires that triggers result in a durable queued row.

  5. vybe commented on Jun 5, 2026

    @vybe
    ContributorAuthor

    Resolved 2026-06-05 — APScheduler on a PostgreSQL job store. Celery/Celery Beat rejected.

    Decision driven by the 2026-06-05 coordination revision (push actor-model → pull / work-stealing; Epic #1045, umbrella #1081):

    • Under pull, task execution moved onto the agents' own worker pools. The scheduler's entire remaining job is "INSERT a queued row on a cron tick" — it never dispatches to or blocks on an agent.
    • Celery is itself a competing-consumers system. Adopting it under pull means running two such systems for no benefit — a broker, worker processes, a result backend, and routing config just to insert a row.
    • APScheduler on a PostgreSQL job store gives durable, restart-surviving schedules. The one thing Celery offered — multi-instance redundancy — comes from a Redis-lock leader election (SET NX EX) over a second APScheduler instance, without Celery's operational surface.
    • Knock-on simplification: PgBouncer (a downstream consequence of Celery prefork workers) and a second runtime are both avoided. PostgreSQL is the only non-negotiable new service.

    Recorded in docs/planning/TARGET_ARCHITECTURE.md §Scheduling and Key Open Questions #4 (now Resolved). Job-store wiring (SQLite → PostgreSQL jobstore) rides #300, not a separate ticket. Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-p3theme-infrastructuretype-docs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions