How we built a paid URL shortener for 1B+ link views

A case study of our paid URL shortener: the PHP, MySQL and Redis architecture behind 1B+ link views and bot-protected clicks.

This is a case study for founders and CTOs who are about to build a product where every request matters and some requests are money. It’s a URL shortener that pays publishers when people visit their links. Here is how it is put together on PHP, MySQL and Redis, and the decisions that let it grow to more than a billion link views.

The product at a glance

A publisher shortens a link and shares it on YouTube, Telegram, WhatsApp, a website or anywhere else. A visitor who opens it sees a short ad page, then continues to the destination. The publisher earns for every 1,000 valid views, at a rate that depends on the visitor’s country.

1B+Link views
25M+Links shortened
100K+Publishers
99.9%Uptime

Figures as of November 2026. The whole platform runs on PHP, MySQL and Redis.

Publishers can shorten links one at a time, in bulk, through a developer API, or across a whole website with a script that converts every link on the page.

That business model shapes the engineering more than the traffic does. In a normal shortener, a miscounted click is a reporting bug. Here, a miscounted click is a payment error, and a fake click is an attempt to take money. So the system has 3 jobs: send visitors on quickly, decide which views are worth paying for, and pay publishers accurately.

The architecture

Architecture: link pages and the dashboard run on PHP, with Redis for caching, counters and queues, background workers, and MySQL as the source of truth
Figure 1. Every click goes through link pages and Redis; everything else can wait.

The design separates traffic by how often it happens and how much it can be allowed to wait.

  • Link pages handle every visit to a short link: find the destination, check for bots, show the ad page, redirect. This is the hot path.
  • The dashboard and API serve publishers and developers: shortening links, stats, earnings and withdrawals. This traffic is far smaller and can afford a database query.
  • Background workers do everything that can happen a few seconds later: validating views, calculating earnings, scanning links for abuse and preparing payouts.
  • Redis holds what must be fast: the link cache, live view counters, rate limits and job queues.
  • MySQL holds what must be correct: links, publishers, validated views, the earnings ledger and payouts.

Why PHP, MySQL and Redis

We chose a well-known stack on purpose. PHP and MySQL are easy to hire for, cheap to host and predictable under load when the hot path is kept small. Redis covers the 2 things a relational database is slow at under heavy traffic: answering the same lookup millions of times, and incrementing counters constantly.

The trade-off is that a PHP request starts fresh every time, so any work the link page does is repeated on every click. That’s why the link page only reads from memory and writes to a queue, and everything else waits for a worker.

From click to destination

The 6 steps of a visit: click, look up, check, ad page, record, redirect
Figure 2. The 6 steps of a visit. Counting and earnings happen after the redirect, in the background.

Every visit follows the same 6 steps.

  1. Click. A visitor opens a short link.
  2. Look up. The code is read from Redis. Only on a cache miss does the request touch MySQL, and the result is then cached. Unknown codes get a not-found page that is also cached briefly, so bots guessing random codes can’t hammer the database.
  3. Check. Bot signals and rate limits are checked in memory. Suspicious visitors still reach the page, but their view isn’t paid.
  4. Ad page. The visitor sees the ad page for a short wait, then continues.
  5. Record. A view event goes into a Redis queue. Nothing about earnings is calculated here.
  6. Redirect. The visitor is sent to the destination with a temporary (302) redirect.

We use a 302 on purpose: a permanent 301 lets browsers remember the destination and skip the server next time, which would make views impossible to count and links impossible to disable once they are reported.

Counting views that are worth paying for

How a click becomes a paid view: automated traffic, repeat views and rate-limited traffic are removed before views are paid
Figure 3. Only views that pass every check are paid.

The product promises bot-protected clicks, and this is the part of the system that needs the most care. Paying for a view means an advertiser paid for a real person to see an ad. Every fake view paid out is money lost, and if advertisers stop trusting the traffic, rates fall for every publisher.

Views pass through layers before they count:

  • Automated traffic is removed. Known bots, crawlers and headless browsers don’t count.
  • Repeat views aren’t counted. The same visitor opening the same link again inside a time window counts once. Redis keeps a short-lived key per visitor and link, so this check costs one memory lookup.
  • Bursts are rate-limited. Unusual spikes from one network, or a publisher clicking their own links, are held back.
  • What’s left becomes paid views.

These checks run in 2 places. The cheap ones run on the link page itself, in Redis. The expensive ones, which look at patterns across many views, run in the workers before a view is marked as validated. That keeps the link page fast, and the heavier analysis still runs on every view before it’s paid.

From views to payouts

From views to payouts: validated views become daily totals per country, are priced with country rates, and are written to an append-only earnings ledger before withdrawals
Figure 4. Earnings live in an append-only ledger, so every balance can be rebuilt.

Publishers are paid for every valid view, so the money side has to be exact.

  • Validated views are totalled per publisher, per country, per day. Rates differ widely by country, so the country has to travel with every view.
  • Earnings are written to a ledger and never edited. Each row records what was earned and at which rate. A balance is the sum of the ledger, so any balance can be rebuilt and checked at any time.
  • Rate changes only apply to new views. Past earnings never move, which avoids disputes and keeps old reports consistent.
  • Withdrawals go through checks. The publisher signs in with two-step sign-in, the payout method and the available balance are verified, and only then is the payout made.

A ledger takes a little more storage than a single balance column, but it turns “why is my balance $4.12?” from an investigation into a query.

Security across the platform

Security here protects 3 groups: visitors, publishers and the platform’s income.

RiskWhat protects against it
Fake or automated viewsBot-protected clicks: bot detection, repeat-view limits and rate limits
Takeover of a publisher accountTwo-step sign-in, plus checks before a payout method changes
Short links pointing to malware or phishingDestination scanning, re-scans, and the public report-abuse page
Scripted bulk shorteningRate limits on link creation and the API
Payout fraudLedger-based balances and checks before every withdrawal
Data exposureEncryption of sensitive data and an audit trail of account changes

Keeping 99.9% uptime

The product promises 99.9% uptime. That allows for about 43 minutes of downtime in a 30-day month, so the design aims to keep the parts that visitors touch working even when other parts don’t.

  • The hot path doesn’t depend on the dashboard, so a slow report or a busy withdrawal day can’t hold up a link page.
  • Redis only holds copies. If cached data is lost, links are read from MySQL again and the cache refills.
  • Workers can fall behind safely. If the queue grows, earnings appear a little later, and visitors and redirects aren’t affected.

What we did by hand at launch

Not everything was automated on day one. We onboarded early publishers ourselves and answered support questions directly. A person can do both well for a small number of users, and a slow reply doesn’t break anything for good. Engineering time went to the parts that can’t fail: the link page, the view checks and the money. Today publishers reach a support team from inside the dashboard.

What founders can take from this

  1. Find your hot path and protect it. List the request your product handles most often and make sure nothing else can slow it down.
  2. If a request is money, treat its data as money. Use a ledger, never edit past amounts, and make every balance rebuildable.
  3. Assume someone will try to game it. Any product that pays for activity needs fraud checks from the first day.
  4. A familiar stack is fine. PHP, MySQL and Redis carried this product past a billion link views. What mattered was keeping the hot path small and the money in a ledger.

If you’re building a product that has to handle this kind of traffic or money, see Custom Software & Web Apps. If you’re deciding what has to be in version 1, see MVP Development.

ShareLinkedInX

Written by Shekhar

Founder of Softregent Technologies, a product team in Pune, India, that designs, builds and scales software products.

Building something that has to handle this much traffic?

We design and build products where speed, security and money handling have to be right from day one. Tell us what you're working on and we'll reply with honest advice and clear next steps.

Start a project →Explore services

← All articles