U
U
Usertouch2019-02-02 11:14:44
Laravel
Usertouch, 2019-02-02 11:14:44

How to solve the problem with Too many requests in server-side rendering?

There are two servers, one with Laravel is used as an API, the second with Nuxt.js with pre-rendering on the SSR server. The problem is that api data is requested from the server directly, and not from the client (user's browser). This happens because we have SSR mode on Nuxt.js. As a result, when different users access the frontend server, we receive many requests to the backend server as if from one client, namely from our frontend server. From this, the backend server cuts off these requests for an error 424 Too many requests.
Question: what to do so that all requests are not cut off? We need SSR mode for SEO so that Yandex can see the pages of our Site.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Ukolov, 2019-02-02
@Usertouch

Configure real ip forward between proxy servers. Example .
Another option: make your own middleware that repeats the standard mechanism for limiting the number of requests, but add an exception for the frontend ip to it.
Forwarding seems to me the most correct solution, but it is not always possible - sometimes the local network is configured crookedly or has a complex structure, and then it is not possible to transfer the external ip.
There is one more nuance: the search bot can still run into these limits, even if you set up the correct ip forwarding - it will simply make more requests than allowed.

H
Hakhagmon, 2020-06-25
@Hakhagmon

Setting up the throttle
middleware Let's make a limit of 5 attempts per minute.

Route::group(['prefix' => 'api', 'middleware' => 'throttle:5'], function () {
  Route::get('people', function () {
    return Person::all();
  });
});

if someone reaches the limit, then he will have to wait 10 minutes.
Route::group(['prefix' => 'api', 'middleware' => 'throttle:5,10'], function () {
    Route::get('people', function () {
        return Person::all();
    });
});

D
Dmitry Ivanov, 2020-10-29
@ivanopol

What was the end of the matter? Same problem

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question