Laravel makes it easy to build features fast, and just as easy to ship an N+1 query that only hurts at 200 users. This guide covers what to test in a Laravel app, how to configure it for a meaningful result, and the bottlenecks that appear most often.
Test the production setup, not artisan serve
php artisan serve handles one request at a time. A load test against it measures the development server, not your app. Test the same stack you run in production:
- PHP-FPM behind Nginx, FrankenPHP, or Octane (Swoole, RoadRunner, FrankenPHP);
APP_ENV=productionandAPP_DEBUG=false(debug mode collects data on every request and is much slower);- caches built:
php artisan optimize(config, routes, events, views); - OPcache enabled, with
opcache.validate_timestamps=0in production; - Telescope and Debugbar off, or at least not recording.
Pick the journeys that matter
Test what users actually do, with the data they actually have:
- Sign in. Password hashing (bcrypt or argon2) is deliberately slow and CPU-heavy. A login storm after an email campaign can saturate CPUs on its own.
- A listing with filters, such as products, orders or search. This is where N+1 queries and missing indexes live.
- A write path, such as checkout or creating a record, with validation, events, queued jobs and emails.
- An authenticated dashboard, which often aggregates a lot of data per request.
Use a dataset of test accounts so each virtual user signs in as someone different, and seed realistic volumes: an index that is not needed with 100 rows is essential with 1,000,000.
Handle CSRF and sessions correctly
Web routes are protected by CSRF tokens. A realistic test does what a browser does:
GET /login, and capture the_tokenvalue from the form (or theXSRF-TOKENcookie);POST /loginwith the email, password and token, keeping the session cookie;- continue with the same cookies for the rest of the journey.
For API routes with Sanctum or Passport, sign in once per virtual user, capture the token from the response, and send it as Authorization: Bearer … on later requests.
The usual bottlenecks
N+1 queries. A list of 50 orders that loads each customer separately makes 51 queries. Under load that becomes thousands of queries per second. Fix with eager loading (Order::with('customer')), and turn on Model::preventLazyLoading() outside production to catch them early.
Missing indexes. Columns used in where, orderBy and joins on large tables need an index. Check slow queries with EXPLAIN.
Too few PHP workers. With PHP-FPM, pm.max_children caps concurrent requests. If it is 10 and each request takes 200 ms, the server tops out at about 50 requests per second no matter how many CPUs are idle. Size it from available memory ÷ memory per worker.
Database connections. Each PHP worker holds a connection. 4 servers × 50 workers = 200 connections, which can exceed PostgreSQL's default max_connections of 100. Use a pooler (PgBouncer) or right-size both sides.
Sessions and cache on the file driver. File locks serialize requests. Use Redis (or Valkey) for sessions, cache and queues.
Synchronous work in the request. Sending email, generating PDFs or calling a slow API inside the request ties up a worker. Queue it.
Read the results per step
Look at each step of the journey separately. If only the order list slows down while login stays flat, the problem is in that query, not in the server. Compare p95 per step against a baseline run, and re-run the same test after each fix.
Laravel with Hoofbeat
Hoofbeat itself is built with Laravel, and its flows handle the details above: capture the CSRF token or a Sanctum token from one step and reuse it in the next, use a dataset of accounts, and keep cookies per virtual user. Describe the journey in HoofbeatChat ("log in to my Laravel app, open orders, filter by status") or import a HAR recording of yourself clicking through it (how). Connect Prometheus and the run page charts your server metrics, such as CPU and database connections, next to latency.