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
🛠 Features✔ Google & GitHub Authentication✔ User Registration & Login✔ Profile/Dashboard Access✔ Secure & Mi...
Flask Blog CMS with Admin Dashboard — Python Source Code
A 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
🚀 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.