Service · Multi

shrt

High-performance URL shortener with custom AOF storage engine, 256-shard index, and SO_REUSEPORT multi-worker architecture achieving ~150K RPS.

In Progress GitHub
5
Languages
256
Shards
~150K
RPS
Zero
Allocation
01

Features

  • fasthttp zero-allocation HTTP engine with pipelining
  • Custom append-only log with 256-shard in-memory index
  • Batched writes and fsync every 5ms
  • sonic SIMD JSON serialization
  • 8-character codes (instance prefix + 7 random base62)
  • SO_REUSEPORT multi-instance kernel load balancing
02

Architecture

Storage Backends
  • In-process AOF with 256-shard in-memory index
  • Dragonfly for distributed caching
  • Redis for traditional key-value storage
  • Pebble LSM-tree storage
  • RocksDB embedded database
Multi-Process Scaling
  • N processes sharing one port via SO_REUSEPORT
  • Per-instance log shards, linear write scaling
  • OS page cache within 5ms
  • fsync every 500ms for durability
03

Implementations

  • Go — Primary implementation with fasthttp
  • Rust — High-performance alternative
  • C++20 — Low-level systems implementation
  • Java — JVM-based version
  • TypeScript — Node.js implementation
04

Benchmarks

Redirect throughput ~197k req/s
Redirect with pipelining ~457k req/s
Single shorten operation ~158k req/s
Bulk shorten (1000 links) ~2.1M rows/s
Go vs TypeScript (writes) ~1.5-2x faster
05

API Endpoints

Core Operations
  • POST /api/shorten — Create shortened links
  • POST /api/shorten/bulk — Batch create up to 10,000 links
  • GET /{code} — Redirect with 302
Admin Operations
  • GET /api/links — Admin listing
  • PATCH /api/links/{code} — Update link
  • DELETE /api/links/{code} — Delete link