How to set the rate limiter for per second in Laravel version 8

Configure Rate Limiter in RouteServiceProvider

Open App\Providers\RouteServiceProvider class and add following changes:

  • The for method accepts a rate limiter name
  • a closure that returns the limit configuration that should apply to routes
/**
     * Configure the rate limiters for the application.
     *
     * @return void
     */
    protected function configureRateLimiting()
    {
        // ALLOW 1500/60 = 25 Request/Sec
        RateLimiter::for('api', function (Request $request) {
            return Limit::perMinute(1500);
        });
        
        
        // ALLOW 1000/60 = 16.66 Request/Sec
        RateLimiter::for('api', function (Request $request) {
            return Limit::perMinute(1000)->response(function () {
                return response('Too many request...', 429);
            });
        });
    }