How to queue requests for an api made with Laravel?

Asked

Viewed 151 times

1

I have an api made in Laravel 5.6, where requests cannot be executed simultaneously and are queued to be executed in the request order. It’s hard to explain an example, but if anyone can help me I’d like to know how to fix it.

  • explain what each request does? maybe a request for sequential events

  • I think I expressed myself badly, in this case it is a single api route, which can only execute one request at a time due to some limitations of its implementation. You should avoid executing multiple requests for this route simultaneously

  • I get it, your doubt is interesting, but, (I’m not sure) this is server stuff, because the server that does this ...

  • Vishi, there’s no way to do it?

  • Who requests is the Server, so the control is in it

  • This control could be done as?

Show 1 more comment

1 answer

0

You can use a feature native to Laravel, the Queues. Roughly they serve to record your tasks in a database table and then go forwarding/executing in the background.

Read the documentation and see some examples:https://laravel.com/docs/5.7/queues

For example, queues allow you to postpone processing a time-consuming task, such as sending an email, until a later time. Postponing these time-consuming tasks dramatically speeds up web requests for your application.

So in your case using Queues will go well.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.