Bang for Buck: Scaling PHP Apps
Measure a Laravel application, remove expensive work, and find the lowest-cost deployment that meets your targets.

Chapters 8
When an application slows down, you can pay for a larger server, change the code, or both. This series gives you a way to compare those choices. You’ll use a small Laravel shop to establish how much correct work it can do, find what limits it, and measure each change against the same traffic.
The shop includes a product catalogue, orders that need a shipping quote, and a worker that produces CSV exports. The lab starts with PHP-FPM, OPcache and PostgreSQL. The benchmark captures what clients see and what the application saves, so you can compare response times, completed work and resource use.
Start measuring
Section titled “Start measuring”- Set a Baseline for a Laravel App — Start the shop and record how it handles a steady workload.
- Test Steady Traffic, Bursts and Cold Starts — Find where targets start to slip and see how the app recovers.
- Profile a Slow Laravel Request — Trace SQL, shipping and PHP CPU time, then reproduce the bottleneck under load.
- Cut Avoidable Work on Every Deploy — Measure the Laravel deployment caches and OPcache on cold and warm requests.
- Ask the Database for Less — Fix repeated queries, select narrower rows and measure cursor pagination.
- Make the Remaining SQL Cheaper — Read a PostgreSQL plan and measure a composite index on live reads and writes in the lab.
- Cache Data with an Expiry and an Owner — Cache a catalogue summary in Redis and measure SQL load during hits, expiry and recovery.
- Move Work Beyond the Response — Compare synchronous and queued CSV exports from the first response to the finished download.
You’ll need a local Code with PHP checkout, Docker with Compose, Bash and curl. The model shop and load generator run inside containers. The later parts of the series use the same app to measure database and cache changes, compare PHP runtimes and test scaling choices.