Most URL shorteners need analytics. Here's how to track clicks efficiently:
Write path: When a user clicks, log asynchronously. Don't block the redirect.
User clicks → Redirect immediately
→ Async: Write to Kafka
→ Consumer: Batch insert to analytics DB
Storage: Time-series data. Consider ClickHouse or TimescaleDB for analytics queries.
Aggregations: Pre-compute hourly/daily counts. Users don't need real-time to the second.