0
0
Laravelframework~8 mins

Queued notifications in Laravel - Performance & Optimization

Choose your learning style9 modes available
Performance: Queued notifications
HIGH IMPACT
This affects how quickly the page responds to user actions by offloading notification sending to background jobs, improving interaction speed.
Sending notifications after user actions without blocking the UI
Laravel
Notification::send($user, (new InvoicePaid($invoice))->delay(now()->addSeconds(5)));
// or using ShouldQueue interface on notification class
$user->notify((new InvoicePaid($invoice))->delay(now()->addSeconds(5)));
Queues the notification to be processed in the background, freeing the request to respond immediately.
📈 Performance GainNon-blocking request, reduces INP by offloading work to queue workers.
Sending notifications after user actions without blocking the UI
Laravel
Notification::send($user, new InvoicePaid($invoice));
Sends notification synchronously, blocking the request until sending completes.
📉 Performance CostBlocks rendering and user interaction for the duration of notification sending, increasing INP.
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
Synchronous notification sendingN/AN/ABlocks server response delaying paint[X] Bad
Queued notification sendingN/AN/AServer responds immediately, faster paint and interaction[OK] Good
Rendering Pipeline
Synchronous notification sending blocks the server response, delaying browser rendering and interaction readiness. Queued notifications defer this work to background processes, allowing the server to send the response faster and the browser to paint and become interactive sooner.
Server Response Time
Interaction Readiness
⚠️ BottleneckServer blocking on notification sending delays response and increases INP.
Core Web Vital Affected
INP
This affects how quickly the page responds to user actions by offloading notification sending to background jobs, improving interaction speed.
Optimization Tips
1Always implement notifications with Laravel's ShouldQueue interface to send asynchronously.
2Avoid sending notifications directly during HTTP requests to prevent blocking response.
3Use queue workers to handle notification jobs in the background for better user experience.
Performance Quiz - 3 Questions
Test your performance knowledge
What is the main performance benefit of using queued notifications in Laravel?
AThey reduce the size of notification payloads sent to users.
BThey allow the server to respond faster by sending notifications asynchronously.
CThey improve the visual layout stability of the page.
DThey increase the number of DOM nodes for notifications.
DevTools: Performance
How to check: Record a performance profile while triggering a notification. Look for long server response times or blocking scripts.
What to look for: Long tasks blocking main thread or delayed server response indicate synchronous notification sending.