MOTOSHARE šŸš—šŸļø
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
šŸš€ Everyone wins.

Start Your Journey with Motoshare

Laravel Throttle Middleware: How to Increase API Rate Limit Safely and for 429 Too Many Requests

If you’re working with Laravel APIs, you might have encountered this default throttle setting:

'api' => [
    'throttle:60,1',
    'bindings',
],

This line lives in your app/Http/Kernel.php file and controls how many requests a user can make to your API. In this blog post, we’ll explore what it means, why you might want to change it, and how to safely increase the rate limit for your Laravel application.


🧠 What Does 'throttle:60,1' Mean?

This throttle rule applies a rate limit to all API requests:

  • 60 = number of requests allowed
  • 1 = time in minutes

šŸ” In short:

Each user (or IP) can make 60 requests per minute to your API.


🚫 Why You Might Want to Change It

You may want to increase the throttle limit if:

  • Your frontend app sends many background requests.
  • You’re integrating with another system (like a mobile app or a microservice).
  • Users are getting 429 Too Many Requests errors frequently.

āœ… How to Increase the Throttle Value

To change the limit, go to:

app/Http/Kernel.php

Find this section:

protected $middlewareGroups = [
    'api' => [
        'throttle:60,1',
        'bindings',
    ],
];

Change it to something like:

'api' => [
    'throttle:200,1', // Allow 200 requests per minute
    'bindings',
],

Tip:

You can adjust this as needed, for example:

  • 'throttle:100,1' → 100 req/min
  • 'throttle:500,5' → 500 requests every 5 minutes

šŸŽÆ Apply Custom Throttle to Specific Routes (Optional)

If you don’t want to increase the throttle globally, you can apply it to specific routes like this:

Route::middleware(['auth:api', 'throttle:300,1'])->get('/profile', function () {
    return response()->json(['user' => auth()->user()]);
});

Or create a group:

Route::middleware(['auth:api', 'throttle:500,5'])->group(function () {
    Route::get('/orders', 'OrderController@index');
    Route::get('/products', 'ProductController@index');
});

Bonus: Create Named Custom Throttle

In RouteServiceProvider.php:

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Support\Facades\RateLimiter;

public function boot()
{
    RateLimiter::for('custom-api', function ($request) {
        return Limit::perMinute(300)->by($request->ip());
    });
}

Then in routes:

Route::middleware(['throttle:custom-api'])->get('/my-endpoint', 'MyController@method');

Laravel makes it easy to control your API traffic using the throttle middleware. If you’re experiencing issues like 429 Too Many Requests, just increasing the limit in Kernel.php or applying custom route-level throttling can solve your problem efficiently.

Related Posts

Boost Your Career with Ansible Training in Bangalore

Bangalore’s tech landscape is booming, and standing out requires mastering the tools that power modern IT infrastructure. At the forefront of this automation revolution is Ansible, the…

Elevate Your IT Career with AIOps Training in the Netherlands

The world of IT operations is evolving at lightning speed, and staying ahead means embracing cutting-edge solutions like AIOps—Artificial Intelligence for IT Operations. For IT professionals in…

AIOps Training in London: Your Path to Smarter IT Operations

Picture this: It’s a hectic Monday morning in London, and your IT systems are screaming with alerts. You’re juggling logs, metrics, and a looming deadline to fix…

AIOps in California: Your Guide to Mastering the Future of IT

The heart of global technology beats in California. From Silicon Valley’s innovative pulse to Los Angeles’s booming tech scene, the state is a living laboratory for the…

Mastering AIOps: A Review of DevOpsSchool’s Premier Training

The digital heartbeat of modern business is loud, complex, and never sleeps. For IT professionals, the constant flood of alerts, performance metrics, and system logs can be…

Elevate Your IT Game: AIOps Training in Canada with DevOpsSchool

The IT world is evolving at breakneck speed, and Canada’s tech hubs—think Toronto, Vancouver, Montreal—are at the forefront. As businesses grapple with sprawling systems and relentless data…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x