Performance: Why background processing improves performance
HIGH IMPACT
Background processing improves page load speed and responsiveness by offloading slow tasks from the main request cycle.
<?php use App\Jobs\SendWelcomeMail; Route::post('/submit', function () { // Dispatch slow task to background SendWelcomeMail::dispatch('user@example.com'); return response('Done'); });
<?php Route::post('/submit', function () { // Slow task done inline Mail::to('user@example.com')->send(new WelcomeMail()); return response('Done'); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous slow tasks in request | Minimal | 0 | Blocks paint until done | [X] Bad |
| Background jobs for slow tasks | Minimal | 0 | Paints immediately, tasks run later | [OK] Good |