Case Study 02

Laravel URL Shortener

The project includes short URL creation, redirects, a visit event and a click-count listener. This makes it ideal for learning how a read-heavy Laravel system grows while keeping the redirect path fast.

1 user — direct lookup is perfect

1 APP SERVER
Browser/abc123
Laravel Server #1resolve short code
MySQL #1short_urls table
302 Redirect

Laravel job

Receives the short code, validates it, queries the indexed short_urls table and returns the redirect response.

No Redis yet

For one user, MySQL is already fast enough. Adding cache has little practical value.

Analytics

The visit event can update click counts after the redirect path so analytics does not become the critical response.

~100 users — cache repeated links

1–2 APP SERVERS
Browsers
Laravel #1–2
Rediscode → destination
MySQLcache miss only
Queue Workerclick analytics

Why Redis?

If the same short links are requested repeatedly, Redis returns the destination from memory and removes repeated database reads.

Why two Laravel servers?

Only if one instance is saturated or you want redundancy. Both servers must use shared Redis/session state rather than local-only cache.

Invalidation

When a destination changes or a link is disabled, remove/update the Redis key so cache and database remain consistent.

~1 million users — distributed redirect tier

4–10 APP SERVERS*
Users
Load Balancer
Laravel Redirect Pool4–10 example nodes
Redis Clusterhot links
MySQL Primary + Replica
Analytics Workers

Critical path

Most redirects should terminate at Redis. MySQL becomes the source of truth and fallback instead of serving every request.

Read replicas

Admin dashboards and historical reporting can use replicas while link creation/edit operations remain on the primary.

Analytics

Buffer click events and aggregate them asynchronously instead of incrementing a database row on every redirect.

~10 million users — edge first

15–40+ ORIGIN APP SERVERS*
Global Users
CDN / Edgepopular redirect cache
Global LB
Laravel Origin Fleet
Redis Shards
Partitioned / Replicated URL Store
Event Streamanalytics pipeline

Why edge caching?

Popular redirects can be answered near the user without reaching your Laravel servers at all, dramatically reducing origin traffic and latency.

Origin fleet

Laravel still handles uncached redirects, link creation, authentication and admin operations. App count depends on edge hit ratio and peak requests per second.

Data partitioning

Partition by short-code hash/range only when storage size or write/query throughput proves that a single primary design is no longer enough.

*Server count is a capacity example

A URL shortener can serve huge registered-user numbers with surprisingly few Laravel servers when edge and Redis cache hit rates are high. The important metric is redirects per second reaching the origin, not total accounts.