Question presented to candidate: "We want to build a photo-sharing app with no servers of our own: code runs on Cloudflare Workers and images live in R2. Design it. Where does each kind of data live, what does a request look like, and what will it cost?"
What a strong answer should cover:
- The model: a Worker runs in every Cloudflare location, is stateless between requests, and has limits (128 MB memory per isolate, CPU time limits per request); all state lives in bound storage services
- Picking the right store per data type: R2 for objects (S3-compatible, no egress fees), the Cache API for hot reads (per location, not replicated), KV for read-mostly config (eventually consistent, up to about 60 s), Durable Objects for anything needing coordination or exact counts, D1 for relational metadata
- The read path: cache first, R2 on a miss, and why per-location caches make the hit rate depend on the number of locations and the catalogue size
- The write path: uploads streamed or presigned straight to R2, metadata in D1, counters and rate limits in Durable Objects, slow work pushed to a queue
- A priced estimate from the published Workers and R2 prices, and what breaks first as traffic grows
Clarifying questions expected:
- Read to write ratio, object sizes, and how much of the catalogue is hot?
- Which data needs strong consistency (counts, purchases, uniqueness) and which can be a minute stale?
- Where are users, and are there data residency requirements?
Code / implementation expected: Optional โ the example simulates per-location caching, a counter in KV versus a Durable Object, and computes the monthly bill.