How it works
If a cache node fails, redirect servers fall back to the database, so protect it with capacity and controlled retry behavior. Using the earlier example, losing one of two cache nodes at a 90% hit rate raises database reads from about 870 to about 4,800 per second. Request coalescing, where concurrent misses for one key share a single database read, and a cap on concurrent queries keep that surge from becoming an outage.
If durable storage is unavailable, existing hot keys may still redirect from cache for a limited time, but creation should not claim success until its mapping is durable. Monitor error rate, redirect latency, cache hit rate, database pressure, and key-generation conflicts.
Validate destination schemes such as http and https and reject unsafe ones such as javascript:. Rate-limit creation, and have a policy for spam, phishing, and malicious destinations. Google’s Safe Browsing API can flag known bad URLs, though a link can turn malicious after creation, so recheck periodically. Do not fetch submitted URLs from privileged infrastructure without defenses against server-side request forgery (SSRF), where a crafted URL makes your own server call an internal address such as a cloud metadata endpoint.
If click analytics is needed, publish an event asynchronously; a failed analytics sink should not usually hold up the redirect. The cost is some lost or delayed events. Reporting tied to billing may not accept that, so it needs a durable local buffer and the extra latency that brings.
An analytics queue is unavailable while people click existing links. Should redirects wait for it?
Usually no. Return the redirect from the mapping path and buffer or drop analytics according to a documented reliability target. Alert on event loss and queue health, but avoid turning a reporting dependency into a redirect outage.
Use this as a guide for self review; written answers are not graded.Keep in mind
- Separate durability of new links from availability of cached redirects.
- Abuse controls and observability are part of the service, not optional polish.