Case Study 01

Scalable Order API

This project uses Laravel controllers, request validation, policies, an order action, events/listeners and CI. Use the four buttons below to see exactly how the same Laravel application can grow from one user to a very large system.

1 user — one Laravel server is enough

1 APP SERVER
Client
Laravel Server #1Nginx + PHP-FPM + app
MySQL #1orders + products + stock

Laravel server job

Receives the HTTP request, authenticates the user, validates input, checks policies, runs CreateOrderAction and returns the response.

Why only one?

There is no traffic pressure. Adding three Laravel servers here creates operational complexity without solving a real problem.

Request flow

Client → Nginx/PHP-FPM → Laravel controller → validation/policy → order transaction → MySQL → response.

~100 users — optimize before multiplying servers

1–2 APP SERVERS
Users
Nginx / LBoptional second node
Laravel #1–2same code, stateless
MySQL Primary
Redis + Workercache / queue

Why 1–2 Laravel servers?

One good server may still be enough. A second instance is useful for redundancy or when CPU/PHP-FPM workers become busy.

Redis job

Shares cache, sessions, rate limits and queue data so two Laravel instances do not depend on local memory.

Worker job

Email, invoices and webhooks move to Laravel queue workers so checkout remains fast.

~1 million users — horizontal application pool

4–12 APP SERVERS*
Clients
Load Balancerhealth checks
Laravel Poolexample: 4–12 instances
Redis Clustercache / locks / queues
MySQL Primary + Replicaswrites / scalable reads
Worker Poolasync side effects

Why many Laravel servers?

The load balancer can send each request to any healthy instance. Because app servers are stateless, more can be added horizontally during peak traffic.

Primary vs replica

Order placement and stock mutation stay on the primary database. Read-heavy history/catalog endpoints can use replicas where consistency rules allow.

Order safety

Idempotency keys, transactions, row locking and retry-safe jobs protect against duplicate requests and concurrent stock updates.

~10 million users — isolate workloads and failure domains

20–60+ APP SERVERS*
Global Clients
CDN / WAF / Gatewayedge + protection
Load Balancers
Laravel Fleetautoscaled zones
Redis Cluster
Partitioned / Replicated Dataprimary write domains + replicas
Queue / Event Fleetworkers + retries + DLQ

What changed?

There are now multiple Laravel app groups across zones, a larger worker fleet, replicated caches and stronger data isolation. One server failure should not stop ordering.

Do we need microservices?

Not automatically. Split inventory, payment or notification only when traffic, ownership, deployment or failure isolation justifies independent services.

Observability

Track request rate, p95/p99 latency, error rate, PHP-FPM saturation, DB locks, replication lag, queue depth and cache hit ratio before changing capacity.

ScaleLaravel app serversDataAsync work
1 user11 MySQLOptional
~100 users1–2Indexed primary + Redis if useful1+ workers
~1M usersExample 4–12*Primary + replicas + Redis clusterWorker pool
~10M usersExample 20–60+*Replicas / partitioning where measuredQueue/event fleet

*Why these server numbers are examples

A “million users” does not tell us requests per second. One million registered users with 2,000 concurrent users is very different from one million concurrent users. Actual Laravel instance count must be load-tested using the endpoint mix, PHP-FPM worker capacity, database latency and target response time.

Laravel deployment chain explained

Nginx receives HTTP traffic and forwards PHP requests to PHP-FPM. PHP-FPM workers execute the Laravel application. Laravel reads/writes MySQL, uses Redis for fast shared state, and publishes slow work to queue workers. A load balancer is added when more than one app server needs to share traffic. Docker can package each role, and GitHub Actions can test code before deployment.