Performance: Scheduler with cron
This affects how efficiently scheduled tasks run in the background without blocking user requests or slowing down the main application.
Jump into concepts and practice - no test required
Set a single cron entry that runs Laravel's scheduler every minute, which internally manages all scheduled tasks.Set up multiple cron entries each running different Laravel artisan commands every minute.
| Pattern | Server Processes | CPU Load | Memory Usage | Verdict |
|---|---|---|---|---|
| Multiple cron entries for each task | Multiple PHP processes per minute | High | High | [X] Bad |
| Single cron entry running Laravel scheduler | One PHP process per minute | Low | Low | [OK] Good |
app/Console/Kernel.php?app/Console/Kernel.php:
$schedule->command('backup:run')->cron('0 3 * * 1');
When will the backup:run command execute?app/Console/Kernel.php:
$schedule->command('report:generate')->cron('60 * * * *');
What is the problem with this cron expression?app/Console/Kernel.php?