0
0
Laravelframework~8 mins

Creating notifications in Laravel - Performance Optimization Steps

Choose your learning style9 modes available
Performance: Creating notifications
MEDIUM IMPACT
This affects how quickly notifications are generated and delivered, impacting server response time and user experience.
Sending notifications after a user action
Laravel
Notification::send($user, (new InvoicePaid($invoice))->onQueue('notifications'));
Queues notification sending to run asynchronously, freeing the request to respond immediately.
📈 Performance GainReduces interaction delay to near zero, improving INP metric significantly.
Sending notifications after a user action
Laravel
Notification::send($user, new InvoicePaid($invoice));
Sends notification synchronously, blocking the request until delivery completes.
📉 Performance CostBlocks server response, increasing interaction delay by 100-300ms depending on notification channel.
Performance Comparison
PatternServer BlockingQueue UsageUser Response DelayVerdict
Synchronous notification sendingHigh (blocks request)NoIncreases by 100-300ms[X] Bad
Queued notification sendingLow (non-blocking)YesMinimal delay[OK] Good
Rendering Pipeline
Notification creation in Laravel runs on the server side and affects how fast the server can respond to user requests. Synchronous notification sending delays response, while queued notifications defer work to background jobs.
Server Processing
Network Response
⚠️ BottleneckServer Processing when notifications are sent synchronously
Core Web Vital Affected
INP
This affects how quickly notifications are generated and delivered, impacting server response time and user experience.
Optimization Tips
1Always queue notifications to avoid blocking user requests.
2Avoid synchronous notification sending in user-facing request cycles.
3Monitor server response times to detect notification-related delays.
Performance Quiz - 3 Questions
Test your performance knowledge
What is the main performance benefit of queuing notifications in Laravel?
AIt reduces the size of the notification payload sent over the network.
BIt improves the visual layout stability of the page.
CIt prevents blocking the user request, improving interaction responsiveness.
DIt decreases the time to first byte (TTFB) for all requests.
DevTools: Network
How to check: Open DevTools Network panel, perform the action triggering notification, and observe server response time.
What to look for: Look for longer server response times indicating synchronous notification sending blocking the request.