Performance5 min read

Finding the real performance problem in a Laravel app

A method for finding where a Laravel app is actually slow, applied to a helpdesk with a million rows: a baseline, the profiler, the database, the cache, the queue and the server, and the instruments to notice next time. Six parts, every number measured.

By Abhishek Fouzdar

Most advice about Laravel performance is a list: add indexes, fix your N+1s, cache things, turn on OPcache, use a queue. The list is correct and it is useless, because it does not say which item is the one your app needs today, and doing all of them is how a team spends a month and moves the 95th percentile by nothing. This series is about finding the real problem: a method for measuring at the layer where the time actually is, applied to a real application with a million rows, on 3 November 2026, with every command's output shown and every change kept only if the numbers kept it.

The application is DeskMini, a helpdesk written the way helpdesks get written, with an inbox, ticket threads, a dashboard, search, a CSV export, an inbound email webhook, an SLA check every minute and a nightly digest, filled with eighteen months of seeded tickets: 200,000 tickets, 1.3 million messages, 40,000 customers. Six parts take it from a dashboard that takes ten seconds for one user and fifty-three for ten, to one that takes fourteen milliseconds and tells you when it stops.

The DeskMini dashboard: counts by status, a thirty-day chart of new tickets, open work by priority, an agents table and the week's top tags

Who this is for

You run or build a Laravel application that has become slow, or will, and you have read the list. Nothing here is beginner material: the series assumes Eloquent, queues and Docker, and spends its words on what the tools show and what the numbers mean. Every part ends with what went wrong while writing it, because that is where half the learning was.

What you will end up with

The application, DeskMini, in the shipbytes/blog-examples repository, one commit per part, with its seeder, the k6 scenarios, every benchmark's summary under bench/results/<part>/, and the instruments: a Server-Timing header, a command that replays a request and groups its queries, php-spx in the image, the slow query log with its digest, a PHP-FPM status page, Horizon, Pulse, Telescope and an OpenTelemetry pipeline into Tempo and Grafana behind a Compose profile. And a method that fits on an index card.

Piece What it teaches
The method and the baseline Name the symptom as a number, reproduce it on data shaped like production, measure at the layer with that layer's tool, change one thing, keep the log. A ramp of layers and instruments, and a baseline nobody can argue with.
The application layer Two instruments that stay in production, a tracing profiler's flame graphs, where the N+1s are and what remains when they are gone, and why the three settings every guide recommends measured nothing on this machine.
The database The slow log and its digest, how to read EXPLAIN, indexes chosen from evidence in two rounds, keyset pagination, full-text search and the bound parameter that made it five times slower, a chunked export, the buffer pool.
Caching What earns a cache and what does not, stale-while-revalidate, the cold-start stampede counted, why invalidation is wrong for a dashboard, HTTP caching, and a cache that looked right and cost more than the query.
Queues, workers and the server The work that was never a request, Horizon, the worker count that shaped every table, PHP and nginx in production, a load test ramped until the host's own ceiling shows.
Observability Pulse, Telescope and OpenTelemetry on the same app, each measured for what it costs, Nightwatch compared from its documentation, and three investigations run through the dashboards.

The parts

  1. The app, the data, a load test and a baseline. The method, the helpdesk as written, a deterministic seeder for a million rows, six k6 scenarios, and the baseline: a ten-second dashboard, a twenty-second search, an export that returns 200 and is wrong.
  2. The application layer: a profiler, flame graphs and the N+1s. Server-Timing, desk:queries, php-spx, 329 queries to 13, preventLazyLoading, a change the profiler liked and the clock could not confirm, and the noise floor of the machine.
  3. The database on a million rows. pt-query-digest, EXPLAIN, two rounds of indexes, cursorPaginate, MATCH … AGAINST and PDO::quote, lazyById, the SLA check as four UPDATEs, innodb_buffer_pool_size.
  4. Caching: what to cache, the stampede, and the cache that looked right. Cache::flexible, a lock on the cold path, counts and search lists for a minute, Cache-Control: immutable, Redis database 1, and twenty-five cache lookups against one subquery.
  5. Queues, workers and the server: the number that shaped every table. ShouldBeUnique, queued mail, an export job on its own queue, Horizon, pm.max_children, /fpm-status, the keepalive that pinned every worker, gzip, the ramp before and after.
  6. Observability: Pulse, Telescope and OpenTelemetry, and what each one costs. Thresholds that would have caught part 1, a trace of a webhook in Grafana, the overhead table, Nightwatch's pricing and mechanism, a job that fails because its row is gone, a job that eats memory.

The numbers, end to end

Ten users for sixty seconds, the same scenarios at the baseline and at the end:

Scenario p50 baseline p50 end p95 baseline p95 end req/s baseline req/s end
dashboard 1.4 s 77 ms 53.1 s 115 ms 0.4 130.8
inbox 1.07 s 208 ms 2.8 s 300 ms 6.4 49.3
ticket 300 ms 188 ms 1.0 s 352 ms 23.5 47.5
search 20.2 s 71 ms 32.5 s 107 ms 0.2 45.2
webhook 54 ms 61 ms 1.37 s 91 ms 10.0 79.8
export, a quarter truncated at 48 s complete, 43 s as a job

For one user, the dashboard went from 10 seconds to 14 milliseconds and the search from 20 seconds to 90. The biggest single steps, in order: the indexes and the grouped queries of part 3 on the dashboard and search, the eager loading of part 2 on the ticket page, the cache of part 4 on the dashboard, the queue of part 5 on the webhook. The PHP settings of part 2 and the worker count of part 5 were the smallest, and the series says so with the measurements that say so.

The decisions

A fresh app, written the usual way. Not a strawman and not a showcase: the inbox partial loads four relations per row because that is what a partial looks like after a year of adding fields, and the dashboard runs thirty whereDate counts because that is the first thing that works. Every slow shape in it is one that exists in production somewhere, and the fixes are the ones a senior engineer would make in that order.

Open tools only. The series spends nothing: k6, php-spx, the slow log, percona-toolkit, Pulse, Telescope, OpenTelemetry, Tempo and Grafana, all in the Compose file. Nightwatch is compared from its documentation and pricing page, honestly and from the outside, because the rule was to spend nothing and the comparison is still worth having.

One laptop, and the noise floor measured. Everything runs in Docker on an eight-core laptop with eleven gigabytes and an old SSD, which makes the absolute numbers meaningless anywhere else and the relative ones the only ones worth reading. Part 2 measures the machine's own drift, 7% between identical runs and 20% across an afternoon, and from then on a change smaller than that is reported as not measurable rather than as an improvement. Two changes that ought to have helped were reverted on that rule.

Every change kept only by its number. The method's last rule is the one that made the series longer and the app smaller: a change that could not be measured was not kept, however well it reads. The repository's history is the changes that were.

What it did not do. It did not get job spans out of Horizon's workers into Tempo, and part 6 says so. It did not run Nightwatch. It did not measure on a server with cores to spare, where part 5's worker count would have been the three-times it was not here. Each is written where it belongs rather than left out.

Where it stands

DeskMini is a working helpdesk with the instruments to know when it stops being a fast one, in a repository anyone can clone, seed in four minutes and measure with one command. The method is six steps and applies to any app in any framework; the tools are the ones this stack happened to need. The dashboard takes fourteen milliseconds, Pulse says so, and the first time it says otherwise the investigation starts at the right layer.

New posts by email

Get new posts by email. Nothing else, no digests, unsubscribe in one click.

Comments

Comments are GitHub Discussions in shipbytes/discussions. Sign in with GitHub to post.