Uploaded October 2026 | Updated November 2026, 3 hours ago
Make one Laravel 13 endpoint faster without buying a bigger server: measure it first, then apply seven fixes one at a time and check each one against the same benchmark.
I start with GET /api/products under load and record median, p95, requests per second, query count and peak memory. Then:
- stop the N+1 queries with eager loading (42 queries → 4)
- add an index that actually matches the query, and check it with EXPLAIN
- select only the columns the response needs
- cache repeatable work, and measure cold and warm separately
- move slow side work (an analytics call) to a queue
- run php artisan optimize, and avoid the env() trap after config:cache
- test Octane against PHP-FPM, and watch for leaked state
The numbers on screen are example data. Run the same benchmark on your own app and record your real results.
Chapters
0:00 Why is this endpoint slow?
0:48 Measure first
1:16 Fix 1 · N+1 queries
2:11 Fix 2 · The right index
2:59 Fix 3 · Only the columns you need
3:42 Fix 4 · Cache repeatable work
4:38 Fix 5 · Side work goes to a queue
5:27 Fix 6 · Production optimizations
6:18 Fix 7 · PHP-FPM vs Octane
7:31 Results
#laravel #php #webperformance
Make one Laravel 13 endpoint faster without buying a bigger server: measure it first, then apply seven fixes one at a time and check each one against the same benchmark.
I start with GET /api/products under load and record median, p95, requests per second, query count and peak memory. Then:
- stop the N+1 queries with eager loading (42 queries → 4)
- add an index that actually matches the query, and check it with EXPLAIN
- select only the columns the response needs
- cache repeatable work, and measure cold and warm separately
- move slow side work (an analytics call) to a queue
- run php artisan optimize, and avoid the env() trap after config:cache
- test Octane against PHP-FPM, and watch for leaked state
The numbers on screen are example data. Run the same benchmark on your own app and record your real results.
Chapters
0:00 Why is this endpoint slow?
0:48 Measure first
1:16 Fix 1 · N+1 queries
2:11 Fix 2 · The right index
2:59 Fix 3 · Only the columns you need
3:42 Fix 4 · Cache repeatable work
4:38 Fix 5 · Side work goes to a queue
5:27 Fix 6 · Production optimizations
6:18 Fix 7 · PHP-FPM vs Octane
7:31 Results
#laravel #php #webperformance










