Case Study

QCK.SH

Sub-50ms redirects. Zero-sampling analytics.

A URL shortening and attribution platform built for raw performance. Every redirect resolved through Rust with multi-layer caching. Analytics powered by ClickHouse for real-time, zero-sampling insights at scale.

Architecture

System Design

Incoming requests hit a Rust HTTP server that checks a Bloom Filter for link existence, then cascades through Moka (in-process L1 cache) and KeyDB (distributed L2 cache) before falling back to PostgreSQL. Click events are asynchronously written to ClickHouse for real-time analytics with zero sampling.

Decisions

Technical Choices

Why Rust

Zero-cost abstractions and no garbage collector pauses. Every microsecond matters on the redirect hot path. Rust gives predictable latency that Go's GC can't guarantee.

Why ClickHouse

Columnar OLAP engine purpose-built for analytics at scale. Zero-sampling means every click is recorded and queryable in real-time. PostgreSQL can't handle this volume of analytical queries efficiently.

Why KeyDB

Multi-threaded Redis-compatible cache. Handles higher throughput than single-threaded Redis with the same API. Acts as the distributed L2 cache layer.

Why Bloom Filter

Probabilistic data structure that answers 'does this short link exist?' in constant time with near-zero memory. Eliminates unnecessary cache/database lookups for non-existent links.

Why Moka Cache

In-process Rust cache with TinyLFU admission policy. Sub-microsecond lookups for hot links without any network hop. Sits between Bloom Filter check and KeyDB.

Performance

Results

<50ms
P50 Latency
99.2%
Cache Hit Rate
0
Sampling Loss

Architecture

Multi-layer caching architecture designed for consistent sub-50ms redirects. Bloom Filter for existence checks, Moka for hot L1 cache, KeyDB for distributed L2, PostgreSQL as source of truth, and ClickHouse for real-time analytics.

Performance Engineering

Every component on the redirect hot path was chosen for predictable, low-latency performance. Rust eliminates GC pauses, Bloom Filter eliminates unnecessary lookups, and the two-tier cache (Moka + KeyDB) ensures most redirects never hit the database.

Tech Stack

Rust PostgreSQL ClickHouse KeyDB Bloom Filter Moka Cache Next.js Astro