One service, two different work paths
Reading and creating links
A shortener maps short keys to long addresses. Visits require fast lookup; creation requires saving a new mapping. Load is 900 visits and 100 creations per second. New link writes must not be lost, even if most visits receive fast responses.
Where caching can help
The cache stores popular mappings and offloads repeated database reads. New links still need persistent storage. Here, the cache sits behind the API, so it does not remove the application’s own work. TTL is also constrained by freshness requirements. A cache-only diagram without a database does not satisfy the task.
Another approach: indexes and capacity
You can speed up lookups with an index and allocate sufficient database capacity without adding a cache. The index increases write cost, and additional databases in the stand distribute work perfectly. Remember this simplification: a real system needs distribution keys, replication and failure handling. Here we compare the budgets of two read strategies.
How to justify your solution
First calculate API capacity for all 1000 operations, then database work for reads and writes. Try two setups: a cache and two databases; an index and two databases. Both require two API servers. The check evaluates conditions and budget, not a match to one reference diagram.
Task
1,000 operations/s: 900 visits and 100 new links. Save every new link and serve reads within 180 units. Use caching or an index and database capacity.
Each API handles 600 operations/s. Each database adds 600 work units/s; load distribution is assumed perfect, with no network or replication overhead. Without an index, lookup=2 units and write=3 units; with one, 0.6 and 4 units. The cache inside the API only removes reads, not API work or writes. All new links must reach the database.
- Add API servers and persistent databases for the required flow.
- Choose read caching or an index; assess the impact on writes.
- Check the architecture and compare it with another component mix.