Serverless Link Management

· 3 min · urlunicorn.com

Architecture

Frontend → CloudFront → API Gateway → Lambda
                                               ↓
                                     DynamoDB (links + analytics)

URL Unicorn handles URL shortening with click analytics, custom aliases, and bulk operations. The redirect path is optimized for speed - under 50ms average.

Fast Redirects

The redirect handler is the most latency-sensitive function. It needs to look up the destination, record the click, and return a 301 - all as fast as possible.

// Redirect handler - optimized for speed
const result = await dynamoDB.get({
    TableName: 'short_urls',
    Key: { slug }
}).promise();

// Track click asynchronously (non-blocking)
trackClick(slug, event).catch(console.error);

return {
    statusCode: 301,
    headers: {
        Location: result.Item.originalUrl,
        'Cache-Control': 'no-cache, no-store'
    }
};

Link Expiration

DynamoDB TTL handles link expiration automatically. Expired links get a soft-delete flag so analytics history is preserved.

Performance