· Updated · 4 min read
Laravel performance in 2026: a production playbook
What actually makes Laravel applications fast in production, from queries and caching to queues and Octane.
Updated 2 November 2026: worked examples for queries, caching and queues, the Octane caveats and a deployment checklist added, from the Laravel and MySQL documentation. Updated 10 October 2026: links to the Laravel and MySQL documentation added.
I've been building and optimizing web applications for clients since 2018, many of them on Laravel. The most dramatic result: the load time of TopGear India's main pages went from 1–3 min → 3 s after the rebuild. Here's the playbook I use on every production Laravel app.
What are the top 4 Laravel performance bottlenecks?
Forget micro-optimizations. Most of the performance problems I see come from these four areas:
1. How do you fix database query bottlenecks?
The N+1 query problem is still the most common performance killer. Use Laravel Debugbar in development and log slow queries in production.
Quick wins:
- Always use eager loading (with()) for relationships
- Add composite indexes for commonly filtered columns
- Use EXPLAIN on your slowest queries
- Replace complex Eloquent chains with raw queries when performance matters
On TopGear India, fixing eager loading and adding proper indexes cut the queries behind the homepage sharply. The case study records the same pattern: the slow pages came from slow SQL, so the queries were rewritten and the tables indexed for how the site actually reads them.
Worked example: an N+1 query. Laravel's documentation shows the pattern. A loop that reads $book->author->name runs one query for the books and then one more per book to fetch its author. Eager loading turns that into two queries, one for the books and one for all their authors:
// Lazy loading: one query for the books, then one per book for its author
$books = Book::all();
foreach ($books as $book) {
echo $book->author->name;
}
// Eager loading: two queries in total
$books = Book::with('author')->get();
foreach ($books as $book) {
echo $book->author->name;
}
To catch the first form before it ships, call Model::preventLazyLoading(! $this->app->isProduction()) in the boot method of your AppServiceProvider. In development and staging Eloquent then throws an exception whenever code lazy loads a relationship, and production keeps running.
Worked example: reading EXPLAIN. Put EXPLAIN in front of the slow query and read two columns. In the MySQL manual, a type of ALL means a full table scan, and you can normally avoid it by adding an index that lets MySQL find the rows from the columns you filter on; ref means rows are read through an index. The key column names the index MySQL actually decided to use, and NULL means it found none. For InnoDB the rows column is an estimate. Run EXPLAIN again after adding the index, because the optimizer decides whether to use it.
2. How should you implement Redis caching in Laravel?
Cache everything that doesn't change per-request. My standard caching strategy:
- Page-level cache: Full HTML responses for anonymous users (5-10 min TTL)
- Fragment cache: Reusable UI components (sidebar, navigation, footer)
- Query cache: Expensive database results (tagged for smart invalidation)
- API cache: Third-party API responses (respect their rate limits)
The key is smart invalidation. I use cache tags extensively — when a post is updated, I invalidate all cache entries tagged with that post's ID rather than flushing everything. Cache tags need a driver that supports them, such as Redis; Laravel doesn't support them with the file, DynamoDB or database drivers.
Worked example: a cache key and its invalidation. The cache entry for a post's rendered fragment carries two tags, one for the post and one for its section. The code is illustrative:
// Read the fragment from the cache, or render it and store it for ten minutes
$html = Cache::tags(["post:{$post->id}", "section:{$post->section_id}"])
->remember("post:{$post->id}:fragment", 600, fn () => view('posts.fragment', compact('post'))->render());
// When the post is updated, flush everything tagged with it, and nothing else
Cache::tags(["post:{$post->id}"])->flush();
Flushing by tag removes every entry that carries that tag. Cache::flush() is the blunt alternative: Laravel's documentation warns that it ignores the configured cache prefix and removes all entries, which matters when the store is shared with other applications. The TopGear write-up, how you cache a newsroom without serving stale stories, goes further into invalidating by what changed.
3. What should you move to Laravel queue workers?
Anything that doesn't affect the immediate HTTP response goes into a queue:
- Email sending
- Image processing
- Webhook dispatches
- Analytics tracking
- PDF generation
- Search index updates
Use Supervisor to manage queue workers and set up dead letter queues for failed jobs.
Worked example: a queued job. A job is a class that implements ShouldQueue. The controller dispatches it and returns at once; a worker runs it later. The code is illustrative:
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Queue\Attributes\Tries;
#[Tries(3)]
class GenerateInvoicePdf implements ShouldQueue
{
use Queueable;
public function __construct(public Order $order) {}
public function handle(): void
{
// build the PDF, store it, notify the customer
}
}
// In the controller: respond now, do the work in a worker
GenerateInvoicePdf::dispatch($order);
Workers are started with php artisan queue:work, and --tries=3 or the #[Tries(3)] attribute shown above limits how many times a failing job is attempted. A worker keeps your code in memory, so reload workers after each deploy; the deployment documentation names php artisan reload for queue workers and Octane, and a process monitor such as Supervisor restarts them when they exit.
4. When does Laravel Octane help?
Octane keeps your Laravel application in memory between requests, so the framework doesn't boot again for every request. It helps most on busy, dynamic pages that can't be cached. It also changes the rules: anything held in memory lives across requests, so singletons and static state need care. Fix queries and caching first; reach for Octane when the bootstrap itself shows up in your measurements.
Octane's documentation names four application servers (FrankenPHP, Open Swoole, Swoole and RoadRunner), and installing it is composer require laravel/octane followed by php artisan octane:install. The caveats are specific. Service providers' register and boot methods run once, when a worker starts, so a singleton that holds the application container or the request keeps serving the old one to later requests. A static array that grows on every request is a memory leak. By default Octane restarts a worker after it has handled 500 requests to limit stray leaks, and php artisan octane:reload loads new code after a deployment.
What should every Laravel deploy do?
Laravel's deployment documentation lists the changes that need no application code:
- Run
php artisan optimizeas part of every deploy. It caches your configuration, events, routes and views. - After configuration is cached, call
env()only inside your config files: the.envfile is no longer loaded, soenv()calls elsewhere returnnull. - Reload long-running services, such as queue workers and Octane, so they use the new code.
- Expose the built-in health route, served at
/upby default, to your uptime monitor or load balancer.
What did this look like on a real site?
On the TopGear India CMS the gains came from architecture and from fixing the slow parts at their source: queries rewritten and tables indexed, Redis caching with an edge CDN in front so most page views never reach the database, images sized for the page, and infrastructure that can be scaled and monitored. The measured load times are at the top of this article and in the case study, where they are attributed to the whole set of changes, not to any one of them. The method for moving such a site without stopping it is in the CodeIgniter to Laravel migration playbook.
What monitoring stack should you use?
You can't optimize what you can't measure. My production monitoring setup:
- Laravel Telescope (development) / Debugbar (disabled in production)
- Slow query logging to dedicated log files
- Redis
INFO statsfor cache hit ratios - NGINX access logs analyzed with GoAccess
- Uptime monitoring with health check endpoints
Performance optimization isn't a one-time project. It's a continuous practice. Set up monitoring first, then fix the bottlenecks the data reveals.
How I do this
If the bottlenecks above sound familiar, a performance and Core Web Vitals audit measures where the time goes before anything is changed. For the queries, indexes and caching behind a slow application, database optimization works from EXPLAIN plans and safe changes to live tables. Laravel development and upgrades covers queue and cache architecture, test coverage and major-version upgrades.
Sources
Related service
- Service: Performance and Core Web Vitals audit · Performance and reliability
Find out in five working days exactly why your application is slow, and what to fix first.
- Service: Legacy modernization · Product engineering
Move an aging system to a modern stack without stopping the business.
- Service: Laravel development and upgrades · Product engineering
Laravel applications and APIs built, upgraded and kept current by an engineer whose main stack is Laravel.
- Service: Database design and query optimization · Performance and reliability
Slow queries found and fixed, schemas that hold at the next stage of growth, and backups that have actually been restored.
Related case study
- Case study: TopGear India CMS · CMS migration and modernization
- page load time, before → after
- 1–3 min → 3 s