Events vs Cron
MySQL Events live in the database itself — no external scheduler required. Cron jobs are more flexible but require server access. Both have valid use cases.
MySQL Events live in the database itself — no external scheduler required. Cron jobs are more flexible but require server access. Both have valid use cases.
-- MySQL Event: good for
-- * Pure SQL operations (purge, aggregate, archive)
-- * Tight database coupling is OK
-- * Simple schedules (every N minutes/hours/days)
-- Cron / application scheduler: good for
-- * Sending emails, calling APIs
-- * Complex business logic
-- * Distributed/clustered environments
-- * Laravel scheduler (recommended for Laravel apps)
-- php artisan schedule:run (in crontab: * * * * *)
-- Schedule::call(fn() => AggregateStats::run())->daily()->at("02:00");
On replicated setups, disable events on replicas — they would duplicate work already done on the primary.