shrty banner

A URL shortener with click analytics, geo-IP lookup, and a write-heavy cache layer. Designed to handle viral-link hot-key scenarios without melting Redis.

Highlights

  • REST API in Go (Fiber or Chi) for short-link creation, redirect, and click-event ingestion with rate-limited public endpoints.
  • Base62 short-code generator with nanoid fallback and collision check against the `links` table before insert.
  • Postgres schema for links, clicks, and referrers, with partitioning on the clicks table by month to bound retention cost.
  • Redis cache in front of Postgres for redirect lookups, with jittered TTLs and read-through replicas to absorb hot-link spikes.
  • Asynchronous click-event ingest path: redirect returns 302 immediately, click is enqueued via Redis Streams and batched into ClickHouse.
  • Geo-IP resolution via MaxMind GeoLite2 served from a Cloudflare Worker edge cache to keep lookup latency under 5 ms.
  • Observability with OpenTelemetry traces, Prometheus metrics (`shrty_redirects_total`, `shrty_cache_hit_ratio`), and pprof in non-prod.
  • Docker Compose stack: app, Postgres 16, Redis 7, ClickHouse, and a seed script that loads 1 M synthetic links for load tests.

Tech Stack

  • Go
  • Postgres
  • Redis
  • ClickHouse
  • OpenTelemetry
  • Docker
  • Cloudflare Workers