code-8
code-8

Reputation: 58662

Best Practice for Laravel Asynchronous Requests

I have a Laravel application. The application loading perfectly fine, when I only make 3-10 API per page in my controller. Now, I start to see the latency when I start making 200 API requests per page in my controller.

Since Laravel is MVC.

All the code in the controller need to be fully executed and finished, and then it will send all the data/variables to the view. But that is leading to a lot of latency.

I’m thinking to perform that APIs call asynchronously, but I am not sure which one is the best move,

I did a quick search, I found :

Any directions/suggestions on this will mean a lot to me, and others that faced this issue.

Upvotes: 5

Views: 23436

Answers (1)

trh88
trh88

Reputation: 633

Explore using Queues for this. Offload any calls to the queue, await for response.

I would recommend against 200 requests per page, it seems excessive. Perhaps start with trying to get that down before rearchitecting.

Upvotes: 2

Related Questions