Jump to content

Queue / Waiting list


PaulieSalieri

Recommended Posts

Hi, users of my Laravel app send requests to my API server (Laravel app, too).

The API server needs around 20 seconds to handle a request (machine learning) and can handle 5 at a time.
I am getting more than 5 requests and would like to put the overhang on a "waiting list".

Once the API server responded to a request, I'd like to send in the next request from the waiting list.

I thought "Laravel Queues" may work.
However, after reading the docs it seems like "Laravel Queues" may not be a good fit.
It seems like that's more for background tasks.

Is there something I am missing or do you have any recommendation how I could handle this?

Thank you ☺️

Edited by PaulieSalieri
Link to comment
Share on other sites

I don't know much about them, but Queues could potentially be useful for this.

The standard solution is to have something running in the background, as in via a cronjob, that periodically looks for tasks and executes them until it runs out. The API server responds to a request with some sort of task identifier that can be polled later, and only queues up the job to be run. When the background process runs it eventually gets around to that job, it updates the status (which could be returned by a poll) and then does whatever it needs to do.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.