Stop Waiting! Speed Up Your Laravel App with Queues (Even on Shared Hosting)

Author

Kritim Yantra

Jul 08, 2025

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.

Tags

Comments

No comments yet. Be the first to comment!

Please log in to post a comment:

Sign in with Google

Related Posts