← Amazon Interview Insights

Amazon·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Amazon SWE interview with a web crawler design question. More depth required than I expected for a coding round, since they pushed pretty hard on the design decisions behind the implementation.

Questions Asked (1)

Q1

Implement a web crawler for a single website. You're given a starting URL, a fetch function that returns HTML or throws an error, and an extractLinks function. Write a BFS crawler that stays within the same domain, normalizes URLs, retries failed fetches up to 3 times, skips permanently failed pages, and never revisits the same URL. Be ready to explain your queue and visited-set design, duplicate detection, and how retry logic fits into the crawl loop.

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

I got the BFS part down pretty fast, queue with a visited set, standard stuff.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and edge cases, then outline a BFS crawler using a queue for URLs to visit and a set for visited URLs. Explain how you normalize URLs, handle retries with a retry count per URL, and ensure domain restriction. Walk through the crawl loop, emphasizing duplicate detection and error handling.

Pro tip: Mention that you would use a separate retry queue or track retry counts to avoid blocking the main queue, and discuss how to handle redirects and URL fragments to demonstrate thoroughness.

1. Clarify requirements and constraints

Ask about domain definition (subdomains?), URL normalization rules, retry semantics (exponential backoff?), and whether concurrency is needed. Confirm that the crawler should be polite and avoid overloading the server.

2. Design data structures

Use a queue (FIFO) for BFS, a set for visited URLs to prevent revisits, and a map or separate queue for retry counts. Explain that the visited set stores normalized URLs to ensure duplicates are caught.

3. Implement URL normalization and domain check

Normalize URLs by lowercasing scheme and host, removing default ports, resolving dot segments, and stripping fragments. Check that the host matches the starting domain (or subdomain if allowed) before enqueueing.

4. Write the BFS crawl loop with retry logic

While the queue is not empty, dequeue a URL, attempt fetch. On failure, increment retry count and re-enqueue if under limit; on success, extract links, normalize and filter, then enqueue unseen URLs. Mark URLs as visited when first enqueued to avoid duplicates.

5. Discuss trade-offs and extensions

Talk about using a priority queue for importance, handling robots.txt, adding delays, and scaling with multiple workers. Mention that retries could be handled with exponential backoff and that permanent failures are skipped after max retries.

Key Points to Mention

  • BFS ensures level-by-level crawling and shortest path to pages.
  • Visited set prevents infinite loops and duplicate work; store normalized URLs.
  • URL normalization includes lowercasing, removing fragments, resolving relative paths.
  • Retry logic: track attempts per URL, re-enqueue on failure up to 3 times, then skip.
  • Domain restriction: compare host of extracted links to starting host.
  • Error handling: catch fetch errors, log permanent failures, continue crawling.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.