LaravelQueuesBackground JobsPerformance
Sending an email during a request can take 2-5 seconds. By moving this to a Queue, your API can respond in 100ms, while the email sends in the background.
Dispatching a Job
php
// Instead of this (Blocking)
Mail::to($user)->send(new WelcomeEmail());
// Do this (Non-Blocking)
SendWelcomeEmail::dispatch($user);