Menu

1 / 2

What a short-link redirect costs: about 4 microseconds in Go

DEV Community: go·Oleksandr Tsoma·about 3 hours ago
#KE9z4UBc
#devtogo#devto#dev#request#redirect
Reading 0:00
15s threshold

A short-link redirect looks like the simplest thing a web service can do: take a slug, return a 301 or 302 . It is also the one request every click on every link has to pass through, so we built it as its own service with a written latency budget.

This post walks through that service: the choices we made, the reasons recorded in our ADRs, a few trimmed excerpts from the code, and a benchmark of what one request costs in-process. The benchmark is local and narrow, and we will say exactly how narrow. The conclusion is a little anticlimactic.

Split by latency budget, not by domain

The first decision (ADR-0013) was to divide the system by how fast each part has to be, not by business area. A link service that handled both redirects and link CRUD would share one latency budget between two very different workloads.

So there are three tiers:

Hot path: edge-redirect only. Target p50 5 ms and p95 15 ms on a cache hit. Nothing synchronous beyond the cache lookup.

Warm path: api-core , analytics-api , billing .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.