Lesson 31 / 32

Interview and Exam Questions

Answer the most common serverless and edge interview questions with structured, trade-off-aware explanations.

By · 15 years in web development

Questions you will be asked, with answer outlines

1. What is a cold start and how do you reduce it? A new environment runs Init before the handler. Reduce it with smaller bundles, setup at module scope, more memory, and provisioned concurrency or snapshots if needed.

2. How do you make a payment-processing function safe against retries? An idempotency key with a conditional write; store the result and return it for duplicates.

3. Why might an edge function be slower than a regional one? It makes repeated round trips to a distant database.

4. How do you stop a traffic spike from overwhelming a relational database? A connection pooler, reserved or maximum concurrency, and a queue to buffer writes.

5. What happens to an async event that keeps failing? Retries, then a DLQ or on-failure destination; without one it is dropped.

6. Edge KV or Durable Object for a like counter? The strongly consistent option, because KV writes propagate slowly.

Walking through a design question

A favourite design prompt is "build a URL shortener on serverless". A strong answer moves in layers. Write path: an HTTP function validates the long URL, generates a short code, and stores it with a conditional write so two requests can never claim the same code. Read path: redirects are read-heavy and latency-sensitive, so serve them at the edge: look up the code in an edge KV store or cache, and return a 301 or 302. Eventual consistency is acceptable because a brand-new link being unavailable in a far PoP for a few seconds rarely matters, and you can fall back to the regional store on a miss. Analytics: count clicks asynchronously with waitUntil and a queue, never on the redirect's critical path. Protection: rate-limit creation, validate URLs against abuse, and keep a least-privilege role for each function. Finish by naming trade-offs and what you would measure.

How to sound like you have shipped it

Interviewers listen for trade-offs and failure handling. For any design, say who retries, where failed events go, how duplicates are handled, what the cold start and cost profile look like, and when you would choose containers instead. That checklist turns a textbook answer into an engineer's answer.

Quick check: In the serverless URL shortener design, why is an eventually consistent edge store acceptable for the redirect lookup?

  • Edge stores are always strongly consistent anyway
  • Redirects are never cached
  • Short codes are recalculated from the long URL on every request
  • Links are read far more than written, and a brief delay before a new link is visible everywhere can be handled with a fallback
Answer

Links are read far more than written, and a brief delay before a new link is visible everywhere can be handled with a fallback — Read-heavy data that rarely changes suits eventual consistency, especially with a fallback to the regional store on a miss.