There is a concept in PHP's laravel framework, which is middleware. You can filter all requests with the specified middleware first.
But it is estimated that in your current situation, you will need to use an in-memory database. Encode the content of the request and insert it into the library (plus the request time field). When responding to the request, first check whether there is a request with the same encoding. If there is no response to the request, if so, compare the time difference before processing.
Users who request too frequently can be added to the blacklist.
Of course, a necessary condition for this is that the user can be identified in the requested content, otherwise it will be difficult.
Write an interceptor and filter it. For filtering two consecutive times separated by more than 10ms
There is a concept in PHP's laravel framework, which is middleware. You can filter all requests with the specified middleware first.
But it is estimated that in your current situation, you will need to use an in-memory database. Encode the content of the request and insert it into the library (plus the request time field). When responding to the request, first check whether there is a request with the same encoding. If there is no response to the request, if so, compare the time difference before processing.
Users who request too frequently can be added to the blacklist.
Of course, a necessary condition for this is that the user can be identified in the requested content, otherwise it will be difficult.