Q: Design TinyURL or bitly (a URL shortening service)

Given a (typically) long URL, how would how would you design service that would generate a shorter and unique alias for it.
Discuss things like:
- How to generate a unique ID for each URL?
- How would you generate unique IDs at scale (thousands of URL shortening requests coming every second)?
- How would your service handle redirects?
- How would you support custom short URLs?
- How to delete expired URLs etc?
- How to track click stats?
https://www.interviewbit.com/problems/design-url-shortener/ is a long discussion.