PaulieSalieri Posted January 4, 2022 Share Posted January 4, 2022 (edited) 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 January 4, 2022 by PaulieSalieri Quote Link to comment https://forums.phpfreaks.com/topic/314386-queue-waiting-list/ Share on other sites More sharing options...
requinix Posted January 5, 2022 Share Posted January 5, 2022 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. Quote Link to comment https://forums.phpfreaks.com/topic/314386-queue-waiting-list/#findComment-1593180 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.