Stop Waiting! Speed Up Your Laravel App with Queues (Even on Shared Hosting)
β Real Talk: Why Is My Laravel App So Slow?
You built your first Laravel app. π
It works! Users can register, reset passwords, maybe even get a confirmation email.
But then... it feels slow. π©
After submitting a form, it hangs for 2β3 seconds.
You stare at the loading spinner and think, βSomethingβs not right.β
Letβs be honest: nobody wants to wait for an email to send before the page reloads.
π‘ Here's the Secret
You donβt need a faster server.
You donβt need Redis or Horizon (yet).
β You just need Laravel Queues.
And the best part?
You can set it up in 10 minutes β even on shared hosting.
Letβs go! π
π§ What Are Laravel Queues (and Why Should I Care)?
Imagine this: You walk into a restaurant. You order 3 biryanis. π
Now, should the cashier:
- Make all 3 biryanis before serving the next customer? β
- OR just take your order, and pass it to the kitchen, so the next customer can order too? β
Laravel queues are that kitchen. π§βπ³
Instead of processing time-heavy tasks right now (like sending emails), Laravel queues them for later β so your app responds instantly, and heavy work happens in the background.
π― Common Use Cases for Queues
- Sending emails π§
- Pushing notifications π
- Generating invoices π§Ύ
- Uploading files to S3 π
- Calling third-party APIs π
- Processing videos, images, or PDFs πΌ
π οΈ How to Set Up Laravel Queues (Without Horizon or Supervisor)
You donβt need to run a daemon or install Redis.
You just need:
- Laravel 10 or 11
- A database queue driver
- A working cron job
- A little Laravel magic πͺ
β Step-by-Step Guide to Laravel Queues on Shared Hosting
1οΈβ£ Set the Queue Driver to Database
Edit your .env:
QUEUE_CONNECTION=database
Then run this:
php artisan queue:table
php artisan migrate
Now your jobs will go into a jobs table.
2οΈβ£ Create Your First Job
php artisan make:job SendWelcomeEmail
Edit the handle() method inside:
use Illuminate\Support\Facades\Mail;
public function handle()
{
Mail::to($this->user->email)->send(new WelcomeMail($this->user));
}
3οΈβ£ Dispatch the Job
Anywhere in your app (like a controller):
SendWelcomeEmail::dispatch($user);
β Done! Itβs in the queue now β ready to be processed.
4οΈβ£ Schedule queue:work in routes/console.php
In Laravel 11+:
use Illuminate\Support\Facades\Schedule;
use Illuminate\Support\Facades\Log;
Schedule::command('queue:work --stop-when-empty')
->everyMinute()
->withoutOverlapping()
->before(function () {
Log::info('Queue started at ' . now());
})
->after(function () {
Log::info('Queue finished at ' . now());
});
5οΈβ£ Set Up Cron in CWP
Command:
cd /home/your-user/public_html && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1
Frequency: Every minute (or every 5, if needed)
Thatβs it β every minute, your app will check the queue and process jobs!
π§ͺ Real Example: Speed Up Signup Emails
Before using queues:
- User registers
- Laravel sends welcome email
- Page takes 3β5 seconds to reload π
After using queues:
- User registers
- Laravel responds in 200ms π
- Email is sent in the background
π₯ Your app feels 10x faster.
And you didn't change servers or buy anything fancy.
β‘ Bonus Tips
β
Use php artisan schedule:list to see upcoming tasks
β
Use Log::info() to debug job runs
β
Use php artisan queue:failed to see failed jobs
β
Retry with php artisan queue:retry all
π§ Recap: You Now Know How To...
- Explain what Laravel queues are
- Set them up using the database driver
- Dispatch background jobs
- Automate them using Laravelβs scheduler
- Use CWP cron to run everything without Supervisor!
And best of all: You did it without needing to install anything. π
π Ready to Take Action?
Try adding a background email or image resize job to your app right now.
Let Laravel do the heavy lifting β and give your users a snappy, smooth experience theyβll love. π
π¬ Letβs Discuss
What's the first task you'd like to push into the background using Laravel queues?
π Drop it in the comments β letβs build faster apps together!
β FAQ: Laravel Queues Made Simple
Q1: Can I use queues without Redis?
Absolutely! Use QUEUE_CONNECTION=database and you're good to go.
Q2: Will the jobs retry automatically if they fail?
Yes β Laravel has retry features built-in. You can customize retry delay, attempt counts, etc.
Q3: Is this safe for production apps?
β Yes! Many Laravel apps on shared hosting use this exact method. Just make sure you test your jobs before going live.
Projects to explore next
Source-code projects from the KritiMyantra catalogue. Check each project's details before buying.
Flask Authentication System (Free Version) - Kritim Yantra
4.3 out of 5 10 reviewsπ Featuresβ Google & GitHub Authenticationβ User Registration & Loginβ Profile/Dashboard Accessβ Secure & Mi...
Flask Blog CMS with Admin Dashboard β Python Source Code
4.5 out of 5 8 reviewsA Flask-based blogging website with a built-in admin dashboard. Manage articles, images, categories, tags and featured p...
Laravel 12 + ReactJS Starter Kit: Add Multi-Language Support (Arabic, English, Spanish) with Blog CRUD
4.5 out of 5 8 reviewsπ Installation & Setup Download & Extract Get the ZIP from kritimyantra.com and extract it. Includes preconfigu...
Comments
No comments yet. Be the first to comment.
Sign in to join the discussion.