Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

seedprod's avatar

Cron or Queue

Hi,

I'm building an app where people can put in a reservation request for a restaurant and my app monitors the restaurant's website to see when the reservation request become available.

There will be multiple users and restaurants.

My question is would it be better to queue each request, so say queue the initial request then re-queue for 15 minutes later if it's still open, then delete the job once closed.

or

Create a cron job that runs every 15 minutes and fires of curl requests for open reservations?

Any input is appreciated.

Thanks

0 likes
2 replies
StuffedGoat's avatar

@seedprod Hey, I came across your questions and just wanted to ask how do you decide to approch this finally? (Your first variant seems good to me.)

Regards

michaeldyrynda's avatar

Either approach would work, however, I think the cron route would be a better option. Queuing is more for getting things done later, whereas cron is for repetitive tasks.

Add a field to your database table to flag whether or not the reservation request became available already, and let the user know you'll contact them somehow (probably email?) when the reservation becomes available. You can then do something like:

App\Reservation::where('condition', false)->get()->each(function ($reservation) {
    if ($reservation->isAvailable()) {
        $reservation->notifyUser();
        $reservation->markAvailable();
    }
});

Wrap this in a scheduled Artisan command and have it check all unconfirmed reservations every y period of time.

Please or to participate in this conversation.